Search
 
SCRIPT & CODE EXAMPLE
 

C

factorial in c using recursion

/* Program Name: Find Factorial
 */
#include<stdio.h>
int find_factorial(int);
int main()
{
   int num, fact;
   //Ask user for the input and store it in num
   printf("
Enter any integer number:");
   scanf("%d",&num);
 
   //Calling our user defined function
   fact =find_factorial(num);
 
   //Displaying factorial of input number
   printf("
factorial of %d is: %d",num, fact);
   return 0;
}
int find_factorial(int n)
{
   //Factorial of 0 is 1 
   if(n==0)
      return(1);
 
   //Function calling itself: recursion
   return(n*find_factorial(n-1));
}
Comment

factorial in c using recursion

/* Program Name: Find Factorial
 */
#include<stdio.h>
int find_factorial(int);
int main()
{
   int num, fact;
   //Ask user for the input and store it in num
   printf("
Enter any integer number:");
   scanf("%d",&num);
 
   //Calling our user defined function
   fact =find_factorial(num);
 
   //Displaying factorial of input number
   printf("
factorial of %d is: %d",num, fact);
   return 0;
}
int find_factorial(int n)
{
   //Factorial of 0 is 1 
   if(n==0)
      return(1);
 
   //Function calling itself: recursion
   return(n*find_factorial(n-1));
}
Comment

PREVIOUS NEXT
Code Example
C :: input in c 
C :: fast inverse square root explained 
C :: c 2d array dimensions 
C :: C how to find substring in string 
C :: pass the pointer to the function 
C :: exclamation mark in c 
C :: c bit access union 
C :: c fractional sleep 
C :: how to empty string in c 
C :: Futter Square Button 
C :: how to checkout branch from commit id 
C :: check if string in string c 
C :: how do you make a copy of a linked list in c 
C :: dynamic memory in c 
C :: c int 
C :: Firebase Connecting with ESP8266 
C :: how to open a file with open in c 
C :: hello word in c 
C :: how to reset all values of 2d vector to 0 
C :: Bootstrap textarea from 
C :: how to make a check bigger 
C :: c remove last charachter from string 
C :: c break statement 
C :: sockaddr_in c 
C :: increment and decrement operator 
C :: Program to print all palindromes in a given range 
C :: Compile multiple C files 
C :: windows make clean 
C :: bitwise operators 
C :: gcc compiler for windows 10 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =