C program to find the factorial of number.|Recursion Function|

Question:

Write a Program in C to take input from user and find the factorial of a given number.

Source Code:

#include<stdio.h> int fact(int num) { if (num==0 || num==1) { return 1; } else { return (num*fact(num-1)); } } int main() { int num1; printf("Enter Number\n"); scanf("%d",&num1); printf("Factorial of numbers is :%d",fact(num1)); return 0; }

Output:

Enter Number 5 Factorial of numbers is:120

Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.