Basic Programs
If Else based Programs
Loop Based Programs
Array Based Programs
String Programs
Function Programs
Pointers Programs
Structure & File Handling Programs
Data Structure Programs
Function based programs
Calculate factorial using function
#include<stdio.h> #include<conio.h>
void main() {
int n=0,f=0;
printf("enter the number");
scanf("%d",&n);
f=fact(n);
printf("factorial of %d is %d",n,f);
}
int fact(int n)
{
int f=1;
while(n>0)
{
f=f*n;
n--;
}
return f;
}
Output of the above program is as following.
Video/ C Introduction
Watch video in full size