Write A Program To Find The Two Repeating Elements in An Array
Write A Program To Find The Two Repeating Elements in An Array
#include<stdio.h>
#include<stdlib.h>
int i, j;
if(arr1[i] == arr1[j]) {
int main() {
int i;
printf("\n");
find2RepetElement(arr1, ctr);
return 0;
}
2.WAP to read 10 numbers and find their sum and average
#include <stdio.h>
int main() {
int numbers[n];
int sum = 0;
float average;
// Input
printf("Enter 10 numbers:\n");
scanf("%d", &numbers[i]);
sum += numbers[i];
// Calculate average
average = (float)sum / n;
// Output
return 0;
}
3. input a string and check it is pallindrome or not#include <stdio.h>
#include <string.h>
int main()
int l = 0;
int h = strlen(str) - 1;
while (h > l) {
if (str[l++] != str[h--]) {
return 0;
return 0;
}
4. Find factorial of a number using pointers.
#include <stdio.h>
int main() {
int fact;
int num1;
printf("------------------------------------------------------\n");
scanf("%d", &num1);
findFact(num1, &fact);
return 0;
int i;
*f = 1;
*f = *f * i;
}
5. Print a right angled triangle with the number increasing by 1.
#include <stdio.h>
int main() {
int i, j, rows, k = 1;
scanf("%d", &rows);
printf("\n");
return 0;
}
6. find power of a number using recursion
#include <stdio.h>
int main() {
scanf("%d", &base);
scanf("%d", &a);
return 0;
if (a != 0)
else
return 1;
}
7. write a program to reverse the elements in an array
#include <stdio.h>
#include <stdlib.h>
#define n 6
int main(){
int temp;
temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
printf("%d,", arr[i]);
}
8. wap to two add distances in inches and feet using structure
#include <stdio.h>
struct Distance {
int feet
float inch;
int main() {
scanf("%d", &d1.feet);
scanf("%f", &d1.inch);
scanf("%d", &d2.feet);
scanf("%f", &d2.inch);
// adding distances
++result.feet;
return 0;
}
9. wap in c to reverse a number
#include <stdio.h>
int main() {
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
n /= 10;
return 0;
}
10. WAP to print the series 1!/1 + 2!/2 + .... + 5!/5 using function
#include <stdio.h>
int fact(int);
void main()
int sum;
sum=fact(1)/1+fact(2)/2+fact(3)/3+fact(4)/4+fact(5)/5;
printf("----------------------------------------------------------\n");
int fact(int n)
int num=0,f=1;
while(num<=n-1)
f =f+f*num;
num++;
return f;
}
11. WAP to print a pyramid that increases by 1
int main() {
int i, j, spc, rows, k, t = 1; // Declare variables 'i' and 'j' for loop counters, 'spc' for spaces, 'rows' for user input, 'k'
for loop counter, 't' for incrementing numbers.
for (k = spc; k >= 1; k--) { // Loop to print spaces before the numbers.
printf(" ");
for (j = 1; j <= i; j++) { // Loop to print numbers based on the current row.
}
12. )wap to check if a number is prime.
#include <stdio.h>
int main() {
int n, i, flag = 0;
scanf("%d", &n);
if (n == 0 || n == 1)
flag = 1;
if (n % i == 0) {
flag = 1;
break;
if (flag == 0)
else
return 0;
}
13. wap to check if a number is prime.#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
printf("------------------------------------------------------------\n");
scanf("%s", str1);
singLet = checkCapital(str1);
if (singLet == 0)
else
printf(" The first capital letter appears in the string %s is %c.\n\n", str1, singLet); }
return 0;
static int i = 0;
if (i < strlen(str2))
if (isupper(str2[i]))
return str2[i];
}
else
i = i + 1;
return checkCapital(str2);
else return 0;
14. WAP to find the first capital letter of a string using recursion
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
printf("------------------------------------------------------------\n");
scanf("%s", str1);
singLet = checkCapital(str1);
if (singLet == 0)
else
printf(" The first capital letter appears in the string %s is %c.\n\n", str1, singLet); }
return 0;
static int i = 0;
if (i < strlen(str2))
if (isupper(str2[i]))
return str2[i];
else
i = i + 1;
return checkCapital(str2);
else return 0;
1+11+111+1111+11111.....upto n terms
#include <stdio.h>
int summation(int n)
int sum = 0, j = 1;
sum = sum + j;
// Appending a 1 at the end
j = (j * 10) + 1;
return sum;
// Driver Code
int main()
int n = 5;
printf("%d", summation(n));
return 0;
}
16. WAP for multiplication table of an integer.
int main() {
int j, n; // Declare variables 'j' for loop counter and 'n' for user input.
printf("Input the number (Table to be calculated) : "); // Print a message to prompt user input.
for (j = 1; j <= 10; j++) { // Start a for loop to calculate the table up to 10.
return 0;
#include <stdio.h>
int main() {
printf("------------------------------------------------------\n");
scanf("%d", &e1);
scanf("%d", &e2);
printf(" element 1 = %d\n element 2 = %d\n element 3 = %d\n", e1, e2, e3);
printf(" element 1 = %d\n element 2 = %d\n element 3 = %d\n\n", e1, e2, e3);
return 0;
int tmp;
tmp = *y;
*y = *x;
*x = *z;
*z = tmp;