Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Working with switch case



Header file



Iterative statement



Comment




Function_ calculate factorial




// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h> #include<math.h> #define pf printf //function declaration int fact(int); int main() { int n,res; pf("Enter any number: "); scanf("%d",&n); //function call res=fact(n); pf("\nFactorial of %d is : %d",n,res); return 0; } //function definition int fact(int x) //function header //function body { int i,f=1; for(i=1;i<=x;i++) f*=i; return f; }
OUTPUT:


© 2018 - All rights reserved