Multiprogramming Language Trainer
Wednesday, 9 November 2016
C Program to find the factorial of a number
#include<stdio.h>
#include<conio.h>
void
main(){
int
i,fact=1,number;
clrscr();
printf(
"Enter a number: "
);
scanf(
"%d"
,&number);
for
(i=1;i<=number;i++){
fact=fact*i;
}
printf(
"Factorial of %d is: %d"
,number,fact);
getch();
}
Output:
Enter a number: 5 Factorial of 5 is: 120
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment