0

Sorry for the maybe stupid question. I wanted to write a straightforward c++ code that takes the number of people and returns how many baking trays of 12 muffins I have to bake when everyone gets two muffins.

So I read in the number so people via cin in the variable "personen" and after that, I calculate the number of the baking trays (variable "bleche") via

  int bleche = ceil(personen/6);

But my code doesn't seem to round up the number. For example if personen = 290, trays is 48 (and not 49).

Can someone tell me why?

Thanks!

#include <iostream>
#include <cmath>
using namespace std;

int main(){
  int personen;
  cout <<"Personen?";
  cin >> personen;

  int bleche = ceil(personen/6);

  cout << "Sie muessen " << bleche << " Backbleche backen." << endl;
  cout << bleche*12 - personen*2 << " Muffins bleiben zur freien Verwendung uebrig." << endl;

  return 0;
}

buttercup
  • 3
  • 3

0 Answers0