## Program to search for a given number in an array using C

/*WAP to search for a given number in an array*/ #include<stdio.h> #include<stdlib.h> void main() { int a[20],i,n,s; clrscr(); printf(“Input the size of an array-\n”); scanf(“%d”,&n); printf(“Enter %d elements-\n”,n); for(i=0;i<n;i++) scanf(“%d”,&a[i]); printf(“Input the number to search-\n”); scanf(“%d”,&s); for(i=0;i<n;i++) if(a[i]==s) { printf(“Number %d found at %d position\n”,s,i+1); exit(0); } printf(“Number %d is not found\n”,s); } Output Input … Read moreProgram to search for a given number in an array using C

## C program to find factorial of a number using function

/*WAP to find factorial of a number using function*/ #include<math.h> #include<stdio.h> main() { int factorial,n; clrscr(); printf(“Enter the number\n”); scanf(“%d”,&n); factorial=fact(n); printf(“Factorial of a given number=%d”,factorial); getch(); } int fact(int a) { int i,f=1; for(i=1;i<=a;i++) f=f*i; return(f); } Output Enter the number 6 Factorial of a given number=720 Download Program Download

## find number & sum of all integer greater than 100 and less than 200 that are divisible by 7 using C

/*WAP to find number & sum of all integer greater than 100 and less than 200 that are divisible by 7*/ #include<stdio.h> void main() { int i,count=0,sum=0; clrscr(); for(i=100;i<=200;i++) if(i%7==0) { count=count+1; sum=sum+i; } printf(“Numbers are Divisible by 7 =%d\n”,count); printf(“Sum of all Integer =%d”,sum); getch(); } Output Numbers are Divisible by 7 =14 Sum … Read morefind number & sum of all integer greater than 100 and less than 200 that are divisible by 7 using C

## Check whether the given number is prime or not using C

/*WAP to check whether the given number is prime or not*/ #include<stdio.h> void main() { int n,i; clrscr(); printf(“Enter A Integer Number-\n”); scanf(“%d”,&n); for(i=2;i<n;i++) { if(n%i==0) { printf(“The Number %d is Not a Prime Number\n”,n); break; } } if(i==n) printf(“The Number %d is Prime Number\n”,n); getch(); } Output Enter A Integer Number- 5 The Number … Read moreCheck whether the given number is prime or not using C

## Detect Armstrong number in 3 digits from 100 to 999 using C

/*WAP to detect armstrong number in 3 Digits from 100 to 999*/ #include<stdio.h> void main() { int i,j,k,number,sumcube; clrscr(); i=1; do { j=0; do { k=0; do { number=i*100+j*10+k; sumcube=(i*i*i)+(j*j*j)+(k*k*k); if(number==sumcube) printf(“%d\n”,number); ++k; } while(k<=9); ++j; } while(j<=9); i++; } while(i<=9); getch(); } Output 13 370 371 407 Download Program Download

## C Program to compute sum and reverse of a given integer

/*WAP to compute sum and reverse of a given integer*/ #include<stdio.h> void main() { int sum=0,rev=0,rem,n; clrscr(); printf(“Enter The Integer-“); scanf(“%d”,&n); while(n!=0) { rem=n%10; sum=sum+rem; rev=rev*10+rem; n=n/10; } printf(“The Sum Of Digits Is =%d\n”,sum); printf(“Reversed Number Is =%d”,rev); getch(); } Output Enter The Integer-248 The Sum Of Digits Is =14 Reversed Number Is =842 Download … Read moreC Program to compute sum and reverse of a given integer

## C Program to calculate roots of a quadratic equation using switch statement

/*WAP to calculate roots of a quadratic equation using switch statement*/ #include<stdio.h> #include<math.h> #include<stdlib.h> void main() { int option; float a,b,c,d,r1,r2; clrscr(); printf(“Enter The Coefficient Of A, B and C\n”);\ scanf(“%f%f%f”,&a,&b,&c); if(a==0) { printf(“Not A Quadratic Equation\n”); exit(0); } d=b*b-4*a*c; if(d==0) option=1; else if(d>0) option=2; else option=3; switch(option) { case 1:printf(“Roots Are Real and Equal … Read moreC Program to calculate roots of a quadratic equation using switch statement

## Swap values of 2 variables without using 3rd variable C Program

C Program to swap 2 Variable or Number without using the third variable
its a simple diploma in computer science 1st semester c lab program