Divide 100 by 33. Produce the answer AND the remainder as shown in the output below.
Both numbers shown above should be stored in variables, BUT the calculations should be done in the output statements. Create variables to store results for this particular exercise. I want you to explore the different ways to do math in this HW. That being said, make sure the two variables with the numbers are referenced in the output.
OUTPUT:
100 divided by 33 equals 3, with a remainder of 1
1-mode)
#include <iostream>
using namespace std;
int main () {
int divisible = 100, divader = 33;
cout << divisible << " divaded by " << divader << " equals " << divisible / divader << ", with a remainder of " << divisible % divader;
return 0;
}
2-mode
#include <iostream>
using namespace std;
int main () {
int divisible = 100, divader = 33;
int division = 0;
while (divisible > divader) {
divisible -= divader;
division++;
}
cout << "100 divaded by 33 equals " << division << ", with a remainder of " << divisible;
return 0;
}
Comments
Leave a comment