C C++ program to generate table of number using recursion

C C++ program to generate table of number using recursion

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C program to generate table of number using recursion

#include<stdio.h>
void table(int,int,int);
int main()
{
    int num,c=1,res;
    printf("Enter a number: ");
    scanf("%d",&num);
    table(num,c,res);
    return 0;
}
void table(int num, int c, int res)
{
    if(c<=10)
    {
        res=num*c;
        printf("%d\n",res);
        table(num,c+1,res);
    }
}

C++ program to generate table of number using recursion

#include<iostream>
using namespace std;
void table(int,int,int);
int main()
{
    int num,c=1,res;
    cout<<"Enter a number: ";
    cin>>num;
    table(num,c,res);
    return 0;
}
void table(int num, int c, int res)
{
    if(c<=10)
    {
        res=num*c;
        cout<<res<<endl;
        table(num,c+1,res);
    }
}

Output of C C++ program to generate table of number using recursion

C C++ program to generate table of number using recursion

More recursion programs in C C++

  1. Series of natural numbers
  2. Factorial of number
  3. Power of number
  4. Fibonacci series
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer