#include"stdio.h"
int main()
{
int n, c;
long int f=1;
printf("\n Enter the number:");
scanf("%d",&n);
if(n<0)
goto end;
for(c=1; c<=n; c++)
f*=c;
printf("\n FACTORIAL IS %ld", f);
end:
getch();
return 0;
}
Enter the number:5
FACTORIAL IS 120
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.