Ein Programm welches das verhalten der Operatoren * und / simuliert (mit Hilfe der Operatoren + und - und Funktionen)
#include<iostream>
using namespace std;
int multiply(int, int);
int divide(int, int);
int main()
{
cout<<"Bitte geben Sie 2 Zahlen ein:\n";
int lhs,rhs;
cin>>lhs;
cin>>rhs;
cout<<rhs<<" ist in "<<lhs<<" "<<divide(lhs,rhs)<<" mal enthalten\n";
cout<<lhs<<" mal "<<rhs<<" ist "<<multiply(lhs,rhs)<<"\n";
}
int multiply(int value, int times)
{
int erg=0;
for(int i=0; i<times; ++i)
{
erg+=value;
}
return erg;
}
int divide(int divisor, int dividend)
{
int erg=0;
while(divisor-dividend >= 0)
{
divisor-=dividend;
++erg;
}
return erg;
}