remainderdump
remainderdump
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
double *data;
scanf("%d", &n);
if (data == NULL) {
exit(0);
}
}
free(data);
return 0;
Arrays3
#include <stdio.h>
#include <stdlib.h>
int main() {
int n, i;
scanf("%d", &n);
if (arr == NULL) {
return 1;
scanf("%d", &arr[i]);
printf("Do you want to resize the array? (Enter new size or 0 to skip): ");
int new_size;
scanf("%d", &new_size);
if (new_size > 0) {
if (arr == NULL) {
return 1;
if (new_size > n) {
scanf("%d", &arr[i]);
n = new_size;
}
// Print the array in reverse order
printf("\n");
free(arr);
return 0;
Arrays4
#include <stdio.h>
// Main function
int main()
int n, mm = 1, ctr = 0; // Declare variables to store array size, mm (unused), and duplicate counter
// Prompt the user to input the number of elements to be stored in the array
scanf("%d", &n);
if (arr[i] == arr[j])
for(j=i+1;j<n;j++)
if(arr[i]==arr[j])
printf("%d\n",arr[i]);
getch();
}
Stack13
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
int data;
} Node;
new_node->data = new_data;
new_node->next = NULL;
return new_node;
Node* head;
} Stack;
if (!new_node) {
printf("\nStack Overflow");
return;
new_node->next = stack->head;
stack->head = new_node;
if (isEmpty(stack)) {
printf("\nStack Underflow\n");
return;
else {
// Assign the current top to a temporary variable
stack->head = stack->head->next;
free(temp);
if (!isEmpty(stack))
return stack->head->data;
else {
printf("\nStack is empty");
return INT_MIN;
int main() {
// Creating a stack
Stack stack;
initializeStack(&stack);
// Push elements onto the stack
push(&stack, 11);
push(&stack, 22);
push(&stack, 33);
push(&stack, 44);
pop(&stack);
pop(&stack);
return 0;
Stack14
#include<stdio.h>
#include<ctype.h>
char stack[100];
void push(char x)
{
stack[++top] = x;
char pop()
if(top == -1)
return -1;
else
return stack[top--];
int priority(char x)
if(x == '(')
return 0;
return 1;
return 2;
return 0;
int main()
char exp[100];
char *e, x;
scanf("%s",exp);
printf("\n");
e = exp;
while(*e != '\0')
if(isalnum(*e))
printf("%c ",*e);
push(*e);
else
printf("%c ",pop());
push(*e);
e++;
while(top != -1)
printf("%c ",pop());
}return 0;
Stack15
#include<stdio.h>
int stack[20];
stack[++top] = x;
int pop()
return stack[top--];
int main()
char exp[20];
char *e;
int n1,n2,n3,num;
scanf("%s",exp);
e = exp;
while(*e != '\0')
if(isdigit(*e))
num = *e - 48;
push(num);
else
n1 = pop();
n2 = pop();
switch(*e)
{
case '+':
n3 = n1 + n2;
break;
case '-':
n3 = n2 - n1;
break;
case '*':
n3 = n1 * n2;
break;
case '/':
n3 = n2 / n1;
break;
push(n3);
e++;
return 0;
}
Tree21
#include<stdio.h>
#include<stdlib.h>
struct node
int data;
};
temporary->data = item;
return temporary;
if (root != NULL)
postorder (root->left);
postorder (root->right);
}
// Here we print the preorder recursively
if (root != NULL)
preorder (root->left);
preorder (root->right);
if (root != NULL)
inorder (root->left);
inorder (root->right);
if (node == NULL)
/* If not then we recur down the tree to find correct position for insertion */
if (data < node->data)
return node;
int main ()
/\
7 14
/\/\
5 8 11 16 */
postorder (root);
preorder (root);
printf ("\nThe inorder is :\n");
inorder (root);
return 0;
Tree22
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
};
newNode->data = data;
return newNode;
if (root == NULL) {
return createNode(data);
}
// Otherwise, recursively insert the data
return root;
if (root != NULL) {
preOrder(root->left);
preOrder(root->right);
if (root != NULL) {
inOrder(root->left);
inOrder(root->right);
postOrder(root->left);
postOrder(root->right);
int main() {
int n, data, i;
scanf("%d", &n);
scanf("%d", &data);
preOrder(root);
inOrder(root);
postOrder(root);
printf("\n");
return 0;
Search23
#include <stdio.h>
int main()
scanf("%d",&number);
scanf("%d",&array[c]);
scanf("%d",&search);
break;
if ( c == number )
return 0;
}
Search24
#include<stdio.h>
int main()
scanf("%d",&n);
scanf("%d",&array[c]);
scanf("%d",&search);
first = 0;
last = n - 1;
middle = (first+last)/2;
first = middle + 1;
break;
else
last = middle - 1;
Sort25
#include <stdio.h>
#include <conio.h>
void main()
scanf("%d", &num);
scanf("%d", &arr[i]);
pos = i;
pos = j;
if(pos != i)
temp = arr[i];
arr[i] = arr[pos];
arr[pos] = temp;
}
printf("\nThe array sorted in ascending order is as follows.\n");
getch();
Sort26
#include <stdio.h>
int main()
scanf("%d", &n);
scanf("%d", &array[c]);
if (array[e] > array[e+1]) /* For decreasing order use '<' instead of '>' */
swap = array[e];
array[e] = array[e+1];
array[e+1] = swap;
}
}
printf("%d\n", array[c]);
return 0;
Sort27
#include <stdio.h>
int main(void)
int n, i, j, temp;
int arr[64];
scanf("%d", &n);
scanf("%d", &arr[i]);
j = i;
temp = arr[j];
j--;
printf("%d\n", arr[i]);
return 0;
Sort28
#include <stdio.h>
#include <stdlib.h>
int i, j, k;
arr[k] = L[i];
i++;
} else {
arr[k] = R[j];
j++;
k++;
arr[k] = L[i];
i++;
k++;
arr[k] = R[j];
j++;
k++;
}
// Free the allocated memory for temporary arrays
free(L);
free(R);
if (l < r) {
int m = l + (r - l) / 2;
mergeSort(arr, l, m);
mergeSort(arr, m + 1, r);
merge(arr, l, m, r);
int main() {
int n, i;
scanf("%d", &n);
scanf("%d", &arr[i]);
}
// Call the mergeSort function
mergeSort(arr, 0, n - 1);
printf("\n");
return 0;