Chapter 5 : Functions & Pointers (Let us C)
Write a function to calculate the factorial value of any integerentered through the keyboard. #include <stdio.h> main() { int a, f; printf("enter any number="); scanf("%d",&a); f=fact(a); printf("%d!=%d",a,f); } fact(int x) { int i,f=1; for(i=x;i>=1;i--) { f=f*i; } } Output: enter any number=33 33!=-2147483648
Comments
Post a Comment