Wednesday 8 August 2012

Write a program using c to print the table of the given no.

/*Write a program using c to print the table of the given no. */
#include<stdio.h>
int table(int, int);
void main()
{
int i,n;
printf("Enter any integer : ");
scanf("%d",&n);
for(i=1;i<=10;i++)
printf("%d x %d = %d \n",n,i,table(n,i));
}
int table(int n, int i)
{
 if(i==1)
  {
    return(n);
    }
 else
  {
    return(table(n,i-1)+n);
    }
}

No comments:

Post a Comment