C programming examples with output
Find factorial of a number
Program
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter any number :");
scanf("%d",&a);
c=a;
b=1;
while(c>0)
{
b=b*c;
c-;
}
printf("Factorial of %d : %d",a,b);
getch();
}
Output
Enter any number:6
Factorial of 6:720
Find factorial of a number
Program
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter any number :");
scanf("%d",&a);
c=a;
b=1;
while(c>0)
{
b=b*c;
c-;
}
printf("Factorial of %d : %d",a,b);
getch();
}
Output
Enter any number:6
Factorial of 6:720
0 komentar:
Post a Comment