Navigation

Saturday, 28 February 2015

PROGRAM FOR TABLE OF ANY NUMBER USING RECURSION

 /*...............PROGRAM FOR TABLE OF ANY NUMBER........*/
void main()
{
    int i,n;
    clrscr();
    printf("Enter any integer ");
    scanf("%d",&n);
    for(i=1;i<=10;i++)
    printf("%d * %d = %d\n",n,i,table(n,i));
    getch();
}
int table(int n, int i)
{
    if(i==1)
    {
        return(n);
    }
    else
    {
        return(table(n,i-1)+n);
    }
}

No comments:

Post a Comment