Programming in C and Computer Fundamentals all Question with solution. What is computer programming. What is difference between all kind of computer. Write a program about difference between programming in C.
Write a program to Calculate Factorial of a number using Recursion.
#include<stdio.h>
#include<conio.h>
main()
{
int a, fact;
printf("\nEnter any number: ");
scanf ("%d", &a);
fact=rec (a);
printf("\nFactorial Value = %d", fact);
}
rec (int x)
{
int f;
if (x==1)
return (1);
else
f=x*rec(x-1);
return (f);
}
No comments:
Post a Comment