Hello.. I finished a program that does multiplication by successive addition.. But now I want to change my program to do division by successive subtraction? I tried to change my while loop to break out sooner but it didn't work... Thanks for any Help!
#include<iostream>
using namespace std;
int div(int m, int n){
int sum = 0;
while(n != 0){
sum = m - sum;
n = n - 1;
}
return sum;
}
int main(){
int m, n;
cout<<"Enter two numbers: ";
cin>>m>>n;
cout<<div(m,n)<<endl;
return 0;
}