Friday, January 31, 2014

Product of two numbers using recursion Implemented by C++

#include<iostream.h>
int pro(int x,int y)
{
    if(y==0)
    return 0;
    else
    return(x+pro(x,y-1));
}


void main()
{
    int a,b,p;
    cout<<"Enter two numbers=";
    cin>>a>>b;
    p=pro(a,b);
    cout<<endl<<"product of two numbers="<<p;
}

No comments:

Post a Comment