November 23, 2024

Wap’C’ Program To Print Multiplication Table Using Recursion

#include<stdio.h>

int mul(int n,int i);
void main()
{
    int n,i=1;
    printf("enter a number\n");
    scanf("%d",&n);
    mul(n,i);
}
int mul(int n,int i)
{
    if(i>10)
    {
        return 0;
    }
    else
    {
        printf("%d*%d=%d\n",n,i,n*i);
        return mul(n,i+1);
    }
}

output:

Enter a number 10
10*1 = 10
10*2 = 20
10*3 = 30
10*4 = 40
10*5 = 50
10*6 = 60
10*7 = 70
10*8 = 80
10*9 = 90
10*10 = 100

Leave a Reply

Your email address will not be published. Required fields are marked *