StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 8. Program to find the factorial of a number using recursion.
Download
  1. C++ Programs list
7. Program to generate the Fibonacci sequence. : 9. Program to implement matrix multiplication using arrays.
C++ Programs list

1.      Program to find the factorial of a number using recursion.

  1. #include <iostream.h>

  2. #include <conio.h>

  3. int factorial(int n) {

  4.     if (n == 0) {

  5.         return 1;

  6.     } else {

  7.         return n * factorial(n - 1);

  8.     }

  9. }

  10.  

  11. int main() {

  12.     int num, result;

  13.     cout << "Enter a non-negative integer: ";

  14.     cin >> num;

  15.     result = factorial(num);

  16.     cout << "The factorial of " << num << " is " << result << endl;

  17.     getch();

  18.     return 0;

  19. }

7. Program to generate the Fibonacci sequence. 9. Program to implement matrix multiplication using arrays.
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website