Get Update on recent Technology & Programming

Showing posts with label C Programs. Show all posts
Showing posts with label C Programs. Show all posts

Wednesday, 15 November 2017

C Program to convert a binary number to a decimal number

C Program to convert a binary number to a decimal number #include<stdio.h> int main(void) { int n,nsave,rem,d,j=1,dec=0; printf("Enter the number in binary : "); scanf("%d",&n); nsave=n; while(n>0) { rem=n%10; /*taking last digit of n*/ d=rem*j;...

C Program to find the factorial of any number

C Program to find the factorial of any number #include<stdio.h> int main(void) { int n,num; long fact=1; printf("Enter a number : "); scanf("%d",&n); num=n; if(n<0) printf("No factorial of negative number\n"); else { while(n>1) { fact*=n;...

C Program to find the product of digits of any number

C Program to find the product of digits of any number #include<stdio.h> int main(void) { int n,prod=1,rem; printf("Enter a number : "); scanf("%d",&n); while(n>0) { rem = n%10; /*taking last digit of n*/ prod*=rem; n/=10;...

C Program to print the sum of digits of any number

C Program to print the sum of digits of any number #include<stdio.h> int main(void) { int n,sum=0,rem; printf("Enter a number : "); scanf("%d",&n); while(n>0) { rem = n%10; /*taking last digit of n*/ sum+=rem;...

C Program to print numbers in reverse order with a difference of 2

C Program to print numbers in reverse order with a difference of 2 #include<stdio.h> int main(void) { int k=10; while(k>=2) { printf("%d\t",k); k=k-2; } printf("\n"); return 0; } ...

C Program to find whether a year is leap or not

C Program to find whether a year is leap or not #include<stdio.h> int main(void) { int year; printf("Enter year : "); scanf("%d",&year); if(year%100 != 0) { if(year%4 == 0) printf("Leap year\n"); else printf("Not leap\n"); }...

Hey, we've just launched a new custom color Blogger template. You'll like it -
Join Our Newsletter