Programming Archives - SeekNLearn.in

c Programs for Prime Numbers

Check a number is prime or not //WAP to check a number is prime or not #include<stdio.h> void main() { int n,i; printf(“Enter a number”); scanf(“%d”,&n); for(i=2;i<n;i++) { if(n%i==0) { printf(“%d is not a prime number”,n); break; } } if(i==n) { printf(“%d is a prime number”,n); } } Display prime Read more…

Calculating Factorial and Summation upto a number using C program

Calculating Factorial using c language //WAP to calculate factorial of a number #include<stdio.h> void main() { int n,s=1,i=1; printf(“Enter a number to calculate upto”); scanf(“%d”,&n); while(i<=n) { s=s*i; i++; } printf(“Factorial of %d is %d”,n,s); } Calculating Summation using c language #include<stdio.h> void main() { int n,i,s=0; printf(“calculate summation upto”); Read more…

Binary to Decimal number and Decimal to Binary Conversion with C program

Decimal to Binary Conversion Using C language //WAP to convert a decimal number to a binary number #include<stdio.h> void main() { int n,i=1,r,ten=1,bin=0; printf(“Enter a decimal number:”); scanf(“%d”,&n); while(n>0) { r=n%2; bin=bin+r*ten; n/=2; ten=ten*10; } printf(“Your binary value is:%d”,bin); } Binary to Decimal Conversion Using C language //WAP to convert Read more…