Cheat Sheets Command Line Cheat Sheet Here we have narrowed down the most required 38 commands one require at command line. 1. Commands For Directories The below command display path of current working directory – Command to Change directory to <directory> Command to Navigate to parent directory Command to List directory contents Command to List detailed directory contents, includinghidden files Command […]
C Programs Linked List in C C Program to Create a Singly Linked List & Display the Elements in the List using function About the program Linked list as we know is an ordered set of data elements, each containing a link to its successor. Program #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *nextptr; }*stnode; void createNodeList(int n); void displayList(); int main() { int n; printf("\n\n Singly Linked List\n"); printf(" Input the number of […]
Blog C program to convert and array in to string Heading Details details details Sub Heading more details Some description Method 1 #include <stdio.h> void main() { int m, n; printf("Enter the values for M and N\n"); scanf("%d %d", &m, &n); if (m == n) printf("M and N are equal\n"); else printf("M and N are not equal\n"); } Now here make sure this text is […]
C Programs Linked List in C C Program to Create a Singly Linked List & Display the Elements in the List using function About the program Linked list as we know is an ordered set of data elements, each containing a link to its successor. Program #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *nextptr; }*stnode; void createNodeList(int n); void displayList(); int main() { int n; printf("\n\n Singly Linked List\n"); printf(" Input the number of […]
C Programs Unions In C C Program to understand concept of Union Union A union is a user-defined data type available in C that allows all members to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Example Keyword used to define it is union. Like here, the union variable Emp has used […]
C Programs Basic Programs C Program to Find the Number of Integers Divisible by 5 and their sum In this program, we will ask the user to provide the minimum value and a maximum value range to be added and find integers divisible by 5 and a total of those integers. To find integers divisible by 5, we will first start a for loop with variable i, which is the minimum value N1 […]
Cheat Sheets Command Line Cheat Sheet Here we have narrowed down the most required 38 commands one require at command line. 1. Commands For Directories The below command display path of current working directory – Command to Change directory to <directory> Command to Navigate to parent directory Command to List directory contents Command to List detailed directory contents, includinghidden files Command […]
Array In C C Program to Compute the Sum of two One-Dimensional Arrays Method 1 using malloc #include <stdio.h> #include <malloc.h> #include <stdlib.h> void main() { int i, n; int *a, *b, *c; printf("How many Elements in each array...\n"); scanf("%d", &n); a = (int *)malloc(n * sizeof(int)); b = (int *)malloc(n * sizeof(int)); c = (int *)malloc(n * sizeof(int)); printf("Enter Elements of First List\n"); for (i = 0; […]
Array In C C Program to Calculate Sum & Average of an Array Method 1 #include <stdio.h> int main() { int Arr[100], n, i, sum = 0; printf("Enter the number of elements you want to insert : "); scanf("%d", &n); for (i = 0; i < n; i++) { printf("Enter element %d : ", i + 1); scanf("%d", &Arr[i]); sum += Arr[i]; } printf("\nThe sum of the array […]
C Programs Linked List in C C Program to Create a Singly Linked List & Display the Elements in the List using function
Loops in C++ C++ Program to Find Factorial For any positive number n, it’s factorial is given by: factorial = 1*2*3...*n Factorial of negative number cannot be found and factorial of 0 is 1. Program #include <iostream> using namespace std; int main() { unsigned int n; unsigned long long factorial = 1; cout << "Enter a positive integer: "; cin >> n; for(int […]
Loops in C++ C++ Program to Calculate Sum of Natural Numbers Program #include <iostream> using namespace std; int main() { int n, sum = 0; cout << "Enter a positive integer: "; cin >> n; for (int i = 1; i <= n; ++i) { sum += i; } cout << "Sum = " << sum; return 0; } Output Enter a positive integer: 50 Sum […]
Array In C C Program to Calculate the Sum of the Array Elements using Pointer Method 1 #include <stdio.h> #include <stdlib.h> int main() { int *ptr,sum=0,n,i; int a[10]; ptr=a; printf(“enter the number of elements\n”); scanf(“%d”,&n); printf(“enter the array elements\n”); for(i=0;i<n;i++) scanf(“%d”,&a[i]); printf(“MEMORY LOCATION OF THE FIRST VALUE %u\n”,&ptr[0]); i=0; while(i<n) { sum=sum+(*ptr); i++; ptr++; } printf(“sum is %d\n”,sum); printf(“FINAL MEMORY LOCATION AFTER ACCESSING %d INTEGERS IS ptr=%u”,n,ptr); return 0; } […]
Array In C C Program to Compute the Sum of two One-Dimensional Arrays Method 1 using malloc #include <stdio.h> #include <malloc.h> #include <stdlib.h> void main() { int i, n; int *a, *b, *c; printf("How many Elements in each array...\n"); scanf("%d", &n); a = (int *)malloc(n * sizeof(int)); b = (int *)malloc(n * sizeof(int)); c = (int *)malloc(n * sizeof(int)); printf("Enter Elements of First List\n"); for (i = 0; […]
Array In C C Program to Find the Largest Two Numbers in a given Array Method 1 Assuming the first element of the array to be the largest and second element to be the next largest value and then swapping with the next element if the next is larger #include <stdio.h> #define MAX 4 void main() { int array[MAX], i, largest1, largest2, temp; printf("Enter %d integer numbers \n", MAX); for […]