Code
Code
Code
#include <stdio.h>
int main() {
int a;
scanf("%d",&a);
if(a>=0)
printf("Positive");
else
printf("Negative");
return 0;
Odd or Even 64
#include <stdio.h>
int main() {
int a;
scanf("%d",&a);
if(a%2==0)
printf("Even");
else
printf("Odd");
return 0;
Greatest of 3
#include <stdio.h>
int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("%d",a);
printf("%d",b);
printf("%d",c);
return 0;
Smallest of 3
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%d",a);
printf("%d",b);
else
printf("%d",c);
return 0;
Eligibility to Vote
#include <stdio.h>
int main() {
int a;
scanf("%d",&a);
if(a>=18)
printf("Eligible");
else
printf("Not Eligible");
return 0;
Divisibility by k 2
#include <stdio.h>
int main() {
int a,b;
scanf("%d%d",&a,&b);
if(a%b==0)
printf("Divisible");
else
printf("Not Divisible");
return 0;
int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("Yes");
else
printf("No");
return 0;
}
Grade for mark
#include <stdio.h>
int main() {
int a;
scanf("%d",&a);
printf("O");
printf("A+");
printf("A");
printf("B+");
printf("B");
else
printf("Re-Appear");
return 0;
Is it a triangle? 1
#include <stdio.h>
int main()
int a1,a2,a3,sum;
scanf("%d%d%d",&a1,&a2,&a3);
sum=a1+a2+a3;
printf("It is a Triangle");
else
printf("It is not a Triangle");
return 0;
int main() {
int year;
scanf("%d", &year);
if (year % 400 == 0)
printf("Leap Year");
else if (year % 4 == 0)
printf("Leap Year");
else
return 0;
Adam’s Charity
#include <stdio.h>
#include <math.h>
int main()
int n,i,sum = 0;
scanf("%d",&n);
for(i=1;i<=n;i++)
sum+=pow(i,2);
printf("%d",sum);
return 0;
}
Sum of Divisors 6
#include <stdio.h>
void sum(int x)
int i, j=0;
for(i=1;i<=x;i++)
if(x%i==0)
j=j+i;
printf("%d",j);
int main() {
int n;
scanf("%d",&n);
sum(n);
return 0;
int main() {
int n;
scanf("%d",&n);
int d=2,r=0,m;
while(n!=0)
if(n%d!=0)
d=d+1;
else
{
m=n;
n=n/d;
if(n==1)
printf("%d",m);
r=1;
break;
return 0;
non prime
#include <stdio.h>
int main() {
int a,b,i,j;
scanf("%d %d",&a,&b);
for(i=a;i<=b;i++)
int d=0;
for(j=1;j<=i;j++)
if(i%j==0)
d++;
if(d!=2)
printf("%d ",i);
return 0;
}
prime or not 32
#include <stdio.h>
void prime(int x)
int i,s=0;
for(i=1;i<=x;i++)
if(x%i==0)
s++;
if(s==2)
printf("Prime");
else
printf("Not Prime");
int main() {
int n;
scanf("%d",&n);
prime(n);
return 0;
Factorial_Number 1
#include<stdio.h>
int main()
int i,fact=1,number;
scanf("%d",&number);
for(i=1;i<=number;i++){
fact=fact*i;
}
printf("%d",fact);
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
void rev(int n)
int a,r=0;
while(n!=0)
a=n%10;
r=r*10+a;
n=n/10;
printf("%d",r);
int main() {
int n;
scanf("%d",&n);
rev(n);
return 0;
int main() {
scanf("%d", &num);
originalNum = num;
while (originalNum != 0) {
originalNum /= 10;
++n;
originalNum = num;
while (originalNum != 0) {
originalNum /= 10;
if (result == num)
printf("Armstrong Number");
else
return 0;
Palindrome or not 13
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n,r,s=0,a=0;
scanf("%d",&n);
a=n;
while(n!=0)
r=n%10;
s=s*10+r;
n=n/10;
if(s==a)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int fact(int n)
int i,f=1;
for(i=1;i<=n;i++)
f=f*i;
return f;
void strong(int n)
int s=0,r,dup=n;
while(n!=0)
{
r=n%10;
s=s+fact(r);
n=n/10;
if(s==dup)
else
int main() {
int n;
scanf("%d",&n);
strong(n);
return 0;
#include <math.h>
int Auto(int n) {
int s=n*n;
while(n>0)
if(n%10!=s%10)
return 0;
n/=10;
s/=10;
}
return 1;
int main() {
int num;
scanf("%d",&num);
if(Auto(num))
else
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n,i,sum=0;
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if(arr[i]>0)
sum=sum+arr[i];
printf("%d",sum);
return 0;
}
Find minimum element 1
#include <stdio.h>
int main() {
int n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
int min=a[0];
for(i=0;i<n;i++)
if(a[i]<min)
min=a[i];
printf("%d",min);
#include <string.h>
#include <math.h>
#include <stdlib.h>
if(n%2==0){
int i;
for(int i=n/2;i>0;i--)
printf("%d ",arr[i-1]);
for(int i=n-1;i>=n/2;i--)
printf("%d ",arr[i]);
else if(n%2==1)
{
int i;
for(int i=n/2;i>0;i--)
printf("%d ",arr[i-1]);
if(n%2==1)
printf("%d ",arr[n/2]);
for(int i=n-1;i>n/2;i--)
printf("%d ",arr[i]);
int main() {
int n;
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++)
scanf("%d",&arr[i]);
rev(arr,n);
Rotate an array 2
#include <stdio.h>
k = k % n;
int temp[k];
int main() {
int n, k;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
scanf("%d", &k);
rotateArray(arr, n, k);
return 0;
Array Sort 2
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
int i, j, a, n, number[30];
scanf("%d", &n);
scanf("%d", &number[i]);
{
for (j = i + 1; j < n; ++j)
a = number[i];
number[i] = number[j];
number[j] = a;
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
return 0;
}
Print without Duplication
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int isUnique = 1;
if (arr[i] == arr[j]) {
isUnique = 0;
break;
if (isUnique) {
return 0;
arr[j + 1] = temp;
if (arr[i] == element) {
return 1;
return 0;
int main() {
scanf("%d", &n1);
int arr1[n1];
scanf("%d", &arr1[i]);
scanf("%d", &n2);
int arr2[n2];
scanf("%d", &arr2[i]);
int mergedSize = 0;
mergedSize++;
merged[mergedSize] = arr2[i];
mergedSize++;
bubbleSort(merged, mergedSize);
return 0;
Print Array 6
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
return 0;
}
Find minimum element 1
#include <stdio.h>
int main() {
int length;
scanf("%d", &length);
int array[length];
scanf("%d", &array[i]);
min = array[i];
printf("%d", min);
return 0;
Replace Elements 1
#include <stdio.h>
int main()
int n;
scanf("%d", &n);
int arr[n];
int ns[n];
scanf("%d", &arr[i]);
}
ns[n - 1] = -1;
if (arr[j]<min)
min=arr[j];
ns[i]=min;
printf("%d ",ns[i]);
return 0;
int main() {
int n, m;
scanf("%d", &a[i]);
}
for (int i = m - 1; i >= 0; i--) {
scanf("%d", &b[i]);
int carry = 0;
if (carry > 0) {
result[len] = carry;
len++;
return 0;
Delete An Element 1
#include <stdio.h>
int i, j;
if (arr[i] == elementToDelete) {
(*size)--;
break;
}
int main() {
int n, i, elementToDelete;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
scanf("%d", &elementToDelete);
return 0;
Palindrome or not 13
#include<stdio.h>
int main()
int n,r,sum=0,temp;
scanf("%d",&n);
temp=n;
while(n>0)
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
if (num <= 1) {
return 0;
if (num % i == 0) {
return 0;
return 1;
int main() {
scanf("%d", &number);
if (isPrime(digit)) {
sum += digit;
number /= 10;
printf("%d", sum);
return 0;
Binary to Octal 4
#include <stdio.h>
while (binaryNumber != 0) {
binaryNumber /= 10;
i++;
i = 1;
while (decimalNumber != 0) {
octalNumber += remainder * i;
decimalNumber /= 8;
i *= 10;
return octalNumber;
int main() {
int binaryNumber;
scanf("%d", &binaryNumber);
printf("%d", octalNumber);
return 0;
}
Number of characters 1
#include <stdio.h>
#include <stdlib.h>
int countCharactersWritten(int n) {
if (n <= 0) {
return 0;
int totalCharacters = 0;
int num = i;
totalCharacters++;
num /= 10;
return totalCharacters;
int main() {
int n;
scanf("%d", &n);
printf("%d",output);
return 0;
int main() {
char str[NO_OF_CHARS];
int count[NO_OF_CHARS] = {0};
scanf("%s", str);
count[str[i]]++;
if (count[str[i]] == 1) {
index = i;
break;
if (index == -1) {
printf("No");
} else {
printf("%c", str[index]);
return 0;
int main() {
char str[100];
int sum = 0;
sum += (int)str[i];
printf("%d", sum);
return 0;
}
Print Vowels
#include <stdio.h>
#include <string.h>
int main() {
char a[100];
gets(a);
int i,n=strlen(a);
for(i=0;i<n;i++)
if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' ||a[i] == 'A' || a[i] == 'E'
printf("%c", a[i]);
return 0;
int main() {
char str[100];
scanf("%s", str);
if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) {
if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' &&
str[i] != 'A' && str[i] != 'E' && str[i] != 'I' && str[i] != 'O' && str[i] != 'U') {
str[i] = '&';
printf("%s", str);
return 0;
}
int main() {
char a[1000];
putchar(a[i]);
return 0;
#include <string.h>
left++;
right--;
binary[left] = binary[right];
binary[right] = temp;
left++;
right--;
int main() {
char binary[100];
scanf("%s", binary);
moveOnesFirst(binary);
printf("%s", binary);
return 0;
Reverse words 7
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int n=strlen(a),i,j=n-1,k;
for(i=n-1;i>=0;i--)
if(a[i]==' ')
for(k=i+1;k<=j;k++)
printf("%c",a[k]);
printf(" ");
j=i-1;
if(i==0)
for(k=i;k<=j;k++)
printf("%c",a[k]);
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int n=strlen(a),i,j=0,k;
for(i=0;i<n;i++)
if(a[i]==' ')
for(k=i-1;k>=j;k--)
printf("%c",a[k]);
printf(" ");
j=i+1;
if(i==n-1)
for(k=i;k>=j;k--)
printf("%c",a[k]);
return 0;
Anagram Check 2
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100],b[100];
gets(a);
gets(b);
int i,f=0;
if(strlen(a)!=strlen(b))
else
int arr[26]={0};
for(i=0;a[i];i++)
// {
// a[i]=a[i]+32;
// }
arr[a[i]-97]++;
arr[b[i]-97]--;
}
for(i=0;i<26;i++)
if(arr[i]!=0)
f=1;
break;
if(f==0)
printf("It is an anagram");
else
return 0;
Check pangram
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int i;
if (isalpha(str[i])) {
count[index] = 1;
int isPangram = 1;
if (count[i] == 0) {
isPangram = 0;
break;
if (isPangram) {
printf("Pangram\n");
} else {
printf("Not Pangram\n");
return 0;
Reverse Vowels 2
#include <stdio.h>
#include <string.h>
int main() {
char input[100];
int left = 0;
char temp;
left++;
}
while (left < right &&
right--;
temp = input[left];
input[left] = input[right];
input[right] = temp;
left++;
right--;
printf("%s", input);
return 0;
Reverse String 31
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
while(i<j)
{
i++;
j--;
if (i<j)
t = a[i];
a[i] = a[j];
a[j] = t;
i++;
j--;
printf("%s",a);
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int arr[26]={0},i;
for(i=0;a[i];i++)
arr[a[i]-97]++;
int max=0,index;
for(i=0;i<26;i++)
if(arr[i]>max)
max=arr[i];
index=i;
printf("%c",index+97);
return 0;
Convert as String
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[50],x;
gets(a);
int t,i,j;
for(i=0;a[i];)
t=0;
x=a[i];
i++;
t=t*10+a[i]-48;
i++;
}
for(j=0;j<t;j++)
printf("%c",x);
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int n=strlen(a),i;
char f[256]={0};
for(i=0;i<n;i++)
f[a[i]]++;
char x1='\0';
char x2='\0';
for(i=0;i<256;i++)
if(f[i]>f[x1])
x2=x1;
x1=i;
}
else if(f[i]>f[x2] && i!=x1)
x2=i;
printf("%c",x2);
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[50];
gets(a);
int n=strlen(a),i,x;
a[0]='0';
a[1]='0';
x=((a[0]-48)*10+(a[1]-48)+12);
a[0]=x/10+48;
a[1]=x%10+48;
for(i=0;i<n-2;i++)
printf("%c",a[i]);
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[50];
gets(a);
int i,j=0,x,y,z,max=0;
for(i=0;i<strlen(a);i++)
if(a[i]==32)
x=i-j;
if(x>max)
y=j;
z=i-1;
max=x;
j=i+1;
if(i==strlen(a)-1)
x=i-j+1;
if(x>max)
{
y=j;
z=i;
max=x;
for(i=y;i<=z;i++)
printf("%c",a[i]);
return 0;
Print X pattern
#include<stdio.h>
int main() {
char str[30];
gets(str);
int n,i,j;
n=strlen(str);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i==j)
printf("%c",str[j]);
else if(i+j==n-1)
printf("%c",str[j]);
}
else
printf(" ");
printf("\n");
Print pattern X
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(i==j||i+j==n-1)
printf("*");
else
printf(" ");
printf("\n");
}
return 0;
#include <stdio.h>
int main() {
scanf("%d", &num);
while (num != 0) {
num /= 10;
printf("%d", reversedNum);
return 0;
2. Armstrong
#include <stdio.h>
#include <math.h>
int main() {
scanf("%d", &num);
originalNum = num;
while (originalNum != 0) {
originalNum /= 10;
++n;
}
originalNum = num;
while (originalNum != 0) {
originalNum /= 10;
if (result == num)
printf("Armstrong Number");
else
return 0;
3. Palindrome
#include <stdio.h>
int main() {
scanf("%d", &num);
originalNum = num;
while (num != 0) {
num /= 10;
if (originalNum == reversedNum)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
}
4. Strong
#include <stdio.h>
int factorial(int n) {
if (n == 0 || n == 1)
return 1;
else
int main() {
scanf("%d", &num);
originalNum = num;
while (num != 0) {
sum += factorial(remainder);
num /= 10;
if (sum == originalNum)
else
return 0;
5. Automorphic
#include <stdio.h>
#include <math.h>
int isAutomorphic(int n) {
int square = n * n;
while (n > 0) {
if (n % 10 != square % 10) {
return 0;
n /= 10;
square /= 10;
return 1;
int main() {
int num;
scanf("%d", &num);
if (isAutomorphic(num)) {
} else {
return 0;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int sum = 0;
if(arr[i]>0)
sum += arr[i];
printf("%d",sum);
return 0;
#include<stdio.h>
int temp;
temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
int i;
printf("\n");
int main()
int a,i;
scanf("%d",&a);
int arr[a];
for(i=0;i<a;i++)
scanf("%d",&arr[i]);
rvereseArray(arr, 0, n-1);
printArray(arr, n);
return 0;
8. Minimum element
#include <stdio.h>
min = arr[i];
}
return min;
int main() {
int n,i;
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if (min != -1) {
printf("%d",min);
return 0;
9. Minimum element
#include <stdio.h>
min = arr[i];
return min;
}
int main() {
int n,i;
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if (min != -1) {
printf("%d",min);
return 0;
#include <stdio.h>
if (num <= 1) {
return 0;
if (num % i == 0) {
return 0;
return 1;
}
int main() {
int n;
scanf("%d", &n);
int num;
scanf("%d", &num);
if (isPrime(num)) {
primes[primeCount] = num;
primeCount++;
} else {
nonPrimes[nonPrimeCount] = num;
nonPrimeCount++;
return 0;
1. Array sort 2
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
int i, j, a, n, number[30];
scanf("%d", &n);
scanf("%d", &number[i]);
a = number[i];
number[i] = number[j];
number[j] = a;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int isUnique = 1;
if (arr[i] == arr[j]) {
isUnique = 0;
break;
if (isUnique) {
return 0;
3. Reverse Array 20
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int start = 0;
int end = n - 1;
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
return 0;
if (num % i == 0) return 0;
return 1;
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int non_prime[n];
int prime[n];
int non_prime_count = 0;
int prime_count = 0;
if (is_prime(arr[i])) {
prime[prime_count++] = arr[i];
} else {
non_prime[non_prime_count++] = arr[i];
}
}
return 0;
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
int sum_of_divisors = 1;
if (num % i == 0) {
sum_of_divisors += i;
if (i != num / i) {
sum_of_divisors += num / i;
}
}
} else {
return 0;
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
int count = 0;
temp /= 10;
count++;
int divisor = 1;
for (int i = 0; i < count; i++) {
divisor *= 10;
} else {
return 0;
7. Rotate an array 2
#include <stdio.h>
k = k % n;
int temp[k];
arr[i] = temp[i];
}
int main() {
int n, k;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
scanf("%d", &k);
rotateArray(arr, n, k);
return 0;
8. Minimum Element 3
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
min = arr[i];
printf("%d", min);
return 0;
#include <stdio.h>
int temp[ars];
temp[i]=a[i];
int p=(i+r)%ars;
a[p]=temp[i];
int main()
int e,r,c;
scanf("%d",&e);
int arr[e];
for (int i=0;i<e; i++) {
scanf("%d",&arr[i]);
scanf("%d",&r);
car(arr,e,r);
scanf("%d",&c);
int i;
scanf("%d",&i);
printf("%d\n",arr[i]);
return 0;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
int sum_even = 0;
int sum_odd = 0;
if (arr[i] % 2 == 0) {
sum_even += arr[i];
} else {
sum_odd += arr[i];
printf("%d", absolute_difference);
return 0;
#include <stdio.h>
if (num < 2) {
return 0;
if (num % i == 0) {
return 0;
return 1;
int main() {
int n, m;
scanf("%d", &arr1[i]);
scanf("%d", &arr2[i]);
leastNonPrime = j;
break;
printf("%d\n", leastNonPrime);
return 0;
#include <stdio.h>
#include <stdlib.h>
int setSize = 0;
int found = 0;
if (set[j] == arr1[i]) {
found = 1;
break;
if (!found) {
set[setSize++] = arr1[i];
int found = 0;
if (set[j] == arr2[i]) {
found = 1;
break;
if (!found) {
set[setSize++] = arr2[i];
}
result = (int*)malloc(setSize * sizeof(int));
result[i] = set[i];
resultSize = setSize;
free(set);
*size = resultSize;
return result;
int main()
int a,b;
scanf("%d%d",&a,&b);
int arr1[a];
for(int i=0;i<a;i++)
scanf("%d",&arr1[i]);
int arr2[b];
for(int i=0;i<b;i++)
scanf("%d",&arr2[i]);
int size = 0;
free(uni);
return 0;
#include <stdio.h>
if (arr[i] == searchNumber) {
return i;
return -1;
int main() {
int n;
scanf("%d", &n);
int cows[n];
scanf("%d", &cows[i]);
int searchNumber;
scanf("%d", &searchNumber);
printf("%d", position);
return 0;
#include <stdio.h>
#include <stdlib.h>
arr[i] = arr[j];
arr[j] = temp;
int i = 0, j = n - 1;
while (i < j)
if (n % 2 != 0)
printf("%d", arr[i]);
}
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
alternateSort(arr, n);
return 0;
#include <stdio.h>
#include <math.h>
int main() {
int a, b;
scanf("%d", &a);
scanf("%d", &b);
int square = i * i;
}
return 0;
#include <stdio.h>
arr[j + 1] = temp;
if (arr[i] == element) {
return 1;
return 0;
int main() {
scanf("%d", &n1);
int arr1[n1];
scanf("%d", &arr1[i]);
}
scanf("%d", &n2);
int arr2[n2];
scanf("%d", &arr2[i]);
int mergedSize = 0;
merged[mergedSize] = arr1[i];
mergedSize++;
merged[mergedSize] = arr2[i];
mergedSize++;
bubbleSort(merged, mergedSize);
return 0;
int main()
int n,x=0,t,i,sum=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
if(n%2==0)
for(i=n/2;i<(3*n)/4;i++)
t=a[i];
a[i]=a[n-1-x];
a[n-1-x]=t;
x++;
for(i=0;i<n;i++){
printf("%d ",a[i]);
if(i%2==0)
sum+=a[i];
printf("\n%d",sum);
else
for(i=n/2+1;i<(3*n)/4;i++)
t=a[i];
a[i]=a[n-1-x];
a[n-1-x]=t;
x++;
for(i=0;i<n;i++){
printf("%d ",a[i]);
if(i%2==0)
sum+=a[i];
printf("\n%d",sum);
3. Print Array 6
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
return 0;
int i,j,t;
for(j=0,j<n,j++)
for(i=0,i<n-1;i++)
if(a[i]<a[i+1])
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
int main()
int n,i,c=1;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,n);
for(i=0;i<n;i++)
if(a[i]!=a[i+1])
c++;
if(c==3)
printf("%d",a[i+1])
break;
if(c!=3)
printf("No");
#include <stdio.h>
int main() {
int length;
scanf("%d", &length);
int array[length];
scanf("%d", &array[i]);
min = array[i];
printf("%d", min);
return 0;
}
6. swap array elements
#include<stdio.h>
int main()
int n,i,k;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&k);
for(i=n-k;i<n;i++)
scanf("%d",&a[i]);
for(i=k;i<n=k;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("%d",&a[i]);
7. Replace element 1
#include <stdio.h>
int main()
int n;
scanf("%d", &n);
int arr[n];
int ns[n];
scanf("%d", &arr[i]);
ns[n - 1] = -1;
if (arr[j]<min)
min=arr[j];
ns[i]=min;
printf("%d ",ns[i]);
return 0;
8. Find count 2
#include<stdio.h>
int n,i,k,s=0;
scanf("%d", &n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&k);
for(i=0;i<n;i++)
s+=a[i]/k;
if(a[i]%k)
s++;
printf("%d",&s);
9. Adding nimber 12
#include <stdio.h>
int main() {
int n, m;
scanf("%d", &a[i]);
scanf("%d", &b[i]);
}
int len = (n > m) ? n : m;
int carry = 0;
if (carry > 0) {
result[len] = carry;
len++;
return 0;
#include <stdio.h>
int i, j;
if (arr[i] == elementToDelete) {
(*size)--;
break;
}
int main() {
int n, i, elementToDelete;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
scanf("%d", &elementToDelete);
return 0;
#include <stdio.h>
while (binaryNumber != 0) {
binaryNumber /= 10;
i++;
}
i = 1;
while (decimalNumber != 0) {
octalNumber += remainder * i;
decimalNumber /= 8;
i *= 10;
return octalNumber;
int main() {
int binaryNumber;
scanf("%d", &binaryNumber);
printf("%d", octalNumber);
return 0;
#include <stdio.h>
#include <math.h>
int main() {
int n;
scanf("%d", &n);
int numDigits = 0;
int temp = n;
while (temp != 0) {
numDigits++;
temp /= 10;
return 1;
int firstHalf = n;
firstHalf /= 10;
int reversedSecondHalf = 0;
while (secondHalf != 0) {
secondHalf /= 10;
printf("%d\n", result);
return 0;
#include <stdio.h>
int main() {
int n, i, c = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
if (n % i == 0) {
c++;
if (c == 2)
printf("Prime Number");
else
return 0;
#include <stdio.h>
if (num <= 1) {
return 0;
if (num % i == 0) {
return 0;
return 1;
int main() {
if (isPrime(digit)) {
sum += digit;
number /= 10;
printf("%d", sum);
return 0;
16. palindrome
#include<stdio.h>
int main()
int n,r,sum=0,temp;
scanf("%d",&n);
temp=n;
while(n>0)
r=n%10;
sum=(sum*10)+r;
n=n/10;
if(temp==sum)
printf("Palindrome");
else
printf("Not Palindrome");
return 0;
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int n=strlen(a),i,j=n-1,k;
for(i=n-1;i>=0;i--)
if(a[i]==' ')
for(k=i+1;k<=j;k++)
printf("%c",a[k]);
printf(" ");
j=i-1;
if(i==0)
for(k=i;k<=j;k++)
printf("%c",a[k]);
return 0;
}
2. String Anagram 5
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100],b[100];
gets(a);
gets(b);
int i,f=0;
if(strlen(a)!=strlen(b))
else
int arr[26]={0};
for(i=0;a[i];i++)
arr[a[i]-97]++;
arr[b[i]-97]--;
for(i=0;i<26;i++)
if(arr[i]!=0)
f=1;
break;
if(f==0)
printf("Anagram");
else
printf("Not Anagram");
return 0;
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char input[100];
scanf("%s", input);
int l=strlen(input);
a[input[i] - 'a'] = 1;
if (a[i] == 0) {
printf("%c", i + 'a');
return 0;
}
4. Reverse vowels in a string 1
#include <stdio.h>
#include <string.h>
int main() {
char input[100];
int left = 0;
char temp;
left++;
right--;
input[left] = input[right];
input[right] = temp;
left++;
right--;
printf("%s", input);
return 0;
#include <stdio.h>
int main()
int b, h=0,i=1,r;
scanf("%d", &b);
while (b!=0)
r=b%10;
h=h+r*i;
i=i*2;
b=b/10;
printf("%X",h);
return 0;
}
Character is vowel or not 1
#include <stdio.h>
int main() {
char ch;
printf("Vowel");
} else {
printf("Not Vowel");
return 0;
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
int main() {
char ch;
if (isupper(ch)) {
printf("UPPER");
} else if (islower(ch)) {
printf("LOWER");
} else if (isdigit(ch)) {
printf("DIGIT");
} else {
printf("SYMBOL");
return 0;
ASCII 12
#include <stdio.h>
int main() {
char ch;
scanf("%c", &ch);
printf("%d",ch);
return 0;
#include <stdlib.h>
int countCharactersWritten(int n) {
if (n <= 0) {
return 0;
int totalCharacters = 0;
int num = i;
totalCharacters++;
num /= 10;
}
}
return totalCharacters;
int main() {
int n;
scanf("%d", &n);
printf("%d",output);
return 0;
#include <string.h>
int main() {
char str[100];
scanf("%s", str);
if (str[i] == str[j]) {
firstDuplicate = str[i];
break;
if (firstDuplicate != '\0') {
break;
}
if (firstDuplicate != '\0') {
printf("%c", firstDuplicate);
} else {
return 0;
Reverse of a String 5
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char a[100];
gets(a);
int i,n=strlen(a);
for(i=n-1;i>=0;i--)
printf("%c",a[i]);
return 0;