Friday, January 31, 2014

Division of two numbers using recursion implemented by C++

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


void main()
{
    int a,b,d;
   cout<<"THIS PROGRAM FOR ONLY INTEGER DIVISION\n";
    cout<<"Enter two numbers=";
    cin>>a>>b;
    d=div(a,b);
    cout<<endl<<"division of two numbers="<<d;
}

No comments:

Post a Comment