Arithmetic Operations

We have some quantity of an item to sell. We want to package it by the dozen. To find how many dozen we can sell and how many we will have left over we must use integers.

1
2
3
4
5
6
7
8
9
10
11
12
13
//Find how many dozen and how many left over for a quantity
#include<iostream>
using namespace std;
int main() {
  int quantity,dozen;
  cout<<"How many do you have:";
  cin>>quantity;
  dozen=quantity/12;
  cout<<"You will have "<<dozen<<" dozen.\n";
  cout<<"You will have "<<quantity%12<<" left over.\n";
  system("pause");
  return 0;
}
CODE
How many do you have? 50
You will have 4 dozen.
You will have 2 left over.
Press any key to continue . . .

Remember, you should try doing each of these programs on your own. Get it to work, break it, modify it, and then try to write it on your own!

NEXT: Order of operations