Hi, i'm second year in college and i'm diving into the basics of c++ , basicly i have to read 2 numbers and divide them with each other by repeated substractions using a function, the function is to divide those numbers by repeatedly substracting one from another, and return the result, and the rest, + give an error in case one of the numbers is 0 :D
i tried to play with that a bit but i think i pretty much failed :(
here is what i got for now:
#include "stdafx.h"
#include <conio.h>
#include <iostream>
using namespace std;
int div (int x, int y)
{
int c=0,d=0;
while (x!=0,y!=0,x>=y)
{
c=x-y;
x=c;
d=d+1;
}
return d;
}
int main()
{
int a,b,c=0,d=0,z=0,n;
cout<<"A= ";
cin>>a;
cout<<" B= ";
cin>>b;
z = div (a,b);
if (a==0 || b==0)
{
cout<<" ERROR "<<endl;
}
if (a!=b,a<=b)
{
cout<<" "<<endl;
cout<<"A / B = "<<z<<endl;
n=a%b;
cout<<"Rest= "<<n<<endl;
}
getch();
}
i get 4 errors but it would be pointless to post them since i know its probably something obvious >.<