Arithmetic Operations

An organization wants to take a trip. We need enough busses to fit everyone. (We can't tell a few people that they can't go.)

Notice that the ceil function will give us the correct number of busses. However, if we divide 30/25 we will get just one. To find the number of busses we multiply either the numerator or denominator by 1.0 to force the value to double.
busses

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//How many busses are needed?
#include<iostream>
#include<cmath>
using namespace std;
int main() {
  int numPeople, numSeats, numBusses;
  cout << "How many people are going:";
  cin >> numPeople;
  cout << "How many seats are there on a bus:";
  cin >> numSeats;
  numBusses = ceil(1.0*numPeople / numSeats);
  cout << "You will need " << numBusses << " busses.\n";
  system("pause");
  return 0;
}
CODE

Notice that we have included the "cmath" header file,

NEXT: Boolean Expressions: true or false