Friday, August 16, 2019

WAP to find factorial of a number.

// C program 

#include<stdio.h>
void main()
{
     int a,f=1;
     clrscr();
     printf("Enter a number:");
     scanf("%d",&a);
     for(int i=1,i<=a;++i);
     {
              f=f*i;
      }
      printf("Factorial of a number is %d",f);
      getch();
}

Sample Input/Output:

Enter a number: 5
Factorial of a number is 120
     

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...