include int main(){int n, i, j, *p, a[10], b[10];printf(“Enter the number of elements :: “);scanf(“%d”, &n); } OUTPUT:Enter the number of elements :: 6Enter the elements : 10 20 30 40 50 60The reversed array :: 60 50 40 30 20 10
Start reading C Program to Reverse Elements in ArrayCategory: C Programs
include int main() {int n1, n2, i, j, *p, *q, a[10], b[10];printf(“Enter the number of elements in array 1 :: “);scanf(“%d”, &n1); } OUTPUT:Enter the number of elements in array 1 :: 5Enter the elements : 1 2 3 4 5Enter the number of elements in array 2 :: 5Enter the elements : 6 7 …
Start reading C Program for MERGING of Two Arrays with out using Third Arrayinclude include struct Node;typedef struct Node * PtrToNode;typedef PtrToNode List;typedef PtrToNode Position; struct Node{int e;Position next;}; void Insert(int x, List l, Position p){Position TmpCell;TmpCell = (struct Node*) malloc(sizeof(struct Node));if(TmpCell == NULL)printf(“Memory out of space\n”);else{TmpCell->e = x;TmpCell->next = p->next;p->next = TmpCell;}} int isLast(Position p){return (p->next == NULL);} Position FindPrevious(int x, List l){Position p = l;while(p->next != …
Start reading C Program to Implement Single Linked List Operationsstruct Node;typedef struct Node * PtrToNode;typedef PtrToNode List;typedef PtrToNode Position; struct Node{int e;Position previous;Position next;}; void Insert(int x, List l, Position p){Position TmpCell;TmpCell = (struct Node*) malloc(sizeof(struct Node));if(TmpCell == NULL)printf(“Memory out of space\n”);else{TmpCell->e = x;TmpCell->previous = p;TmpCell->next = p->next;p->next = TmpCell;}} int isLast(Position p){return (p->next == NULL);} Position Find(int x, List l){Position p = l->next;while(p …
Start reading C Program to Implement Doubly Linked List Operations/* Binary search program in C using both recursive and non recursive functions */ include define MAX_LEN 10 /* Non-Recursive function*/void b_search_nonrecursive(int l[],int num,int ele){int l1,i,j, flag = 0;l1 = 0;i = num-1;while(l1 <= i){j = (l1+i)/2;if( l[j] == ele){printf(“\nThe element %d is present at position %d in list\n”,ele,j);flag =1;break;}elseif(l[j] < ele)l1 = j+1;elsei = …
Start reading Binary Search Program in C using Recursive and Non-Recursive Methodsvoid binary(int val);int main(){int a,b;printf(“Enter the number in decimal:”);scanf(“%d”,&a);printf(“Number in Binary form: “);binary(a);return 0;}void binary(int val){int r;r=val%2;val=val/2;if(val==0){printf(“%d”,r);}else{binary(val);printf(“%d”,r);}} OUTPUT: Enter the number in decimal:10Number in Binary form: 1010
Start reading Decimal to Binary Conversion Using Cint main(){int a[200],n,counter,temp,i;a[0]=1;counter=0;printf(“Enter the number to Find Factorial: “);scanf(“%d”,&n);for(; n>=2; n–){temp=0;for(i=0; i<=counter; i++) { temp=(a[i]*n)+temp; a[i]=temp%10; temp=temp/10; } while(temp>0){a[++counter]=temp%10;temp=temp/10;}}for(i=counter; i>=0; i–)printf(“%d”,a[i]);return 0;}OUTPUT: Enter the number to Find Factorial: 10093326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
Start reading Compute Factorial of Large Numbers using C// Function to find largest elementint largest(int a[], int n){int large = a[0], i;for(i = 1; i < n; i++){if(large < a[i])large = a[i];}return large;} // Function to perform sortingvoid RadixSort(int a[], int n){int bucket[10][10], bucket_count[10];int i, j, k, remainder, NOP=0, divisor=1, large, pass; } //program starts hereint main(){int i, n, a[10];printf(“Enter the number of …
Start reading C Program to Implement RADIX SORTvoid Merge(int a[], int tmp[], int lpos, int rpos, int rend){int i, lend, n, tmppos;lend = rpos – 1;tmppos = lpos;n = rend – lpos + 1; } void MSort(int a[], int tmp[], int left, int right){int center;if(left < right){center = (left + right) / 2;MSort(a, tmp, left, center);MSort(a, tmp, center + 1, right);Merge(a, tmp, …
Start reading Merge Sort Program in CPUSH function in the code is used to insert an element to the top of stack, POP function used to remove the element from the top of stack. Finally, the display function in the code is used to print the values. All stack functions are implemented in C Code. include int stack[100],choice,n,top,x,i;void push(void);void pop(void);void display(void);int …
Start reading Implementation of Stack Using Array in C