Friday 25 July 2014

program to display the multiplication table of a number.it uses recursion.

#include<iostream>
#include<iomanip>
#include<iostream>
using namespace std;
int product(int k, int i);

int main()
{
int i, k;
cout<<"enter any integer number ";
cin>>k;
for(i=1;i<=10;i++)
cout<<setw(4)<<k<<"*"<<setw(3)<<i<<"="<<setw(4)<<product(k,i)<<endl;
}

//function to evaluate the factorial
int product(int k,int i)
{
if(i==1)
 return(k);
else
 return(product(k,i-1)+k);
}

No comments:

Post a Comment

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...