Program to find Factorial of a Number using Recursion

Program to find Factorial of a Number using Recursion

Program to find Factorial of a Number using Recursion #include<stdio.h> // declaring the function int fact(int); int main() { printf(“\n\n\t\tEduguru – Recursion Program Example\n\n\n”); int num, f; printf(“\n\nEnter a number: “); scanf(“%d”, &num); f= fact(num); printf(“\n\nFactorial of %d is %d\n\n”, num, f); printf(“\n\n\t\t\tCoding is Fun here !\n\n\n”); return 0; } int fact(int aj) { if(aj==1 … Read more

C Program for Adding Two Numbers Using Recursion

c program to add 2 numbers

C Program for Adding Two Numbers Using Recursion #include<stdio.h> int y; /* Function to add two numbers and return the result */ int add(int m, int n) { if(n == 0) return m; /* Recursion: adding 1, n times and then at the end adding m to it */ y = add(m, n-1) + 1; … Read more

C Program find whether a Number is Prime Or Composite using Recursion

prime number

C Program find whether a Number is Prime Or Composite using Recursion Prime Number: A number that is only divisible by 1 and itself. Composite Number: A number that is not a prime number. Note: 1 is neither prime nor composite. Below is a program to find whether the user input number is a prime number or a … Read more