
If statements
Hi, i am new to c++ and i am writing a program to calculate the number of buses, for a group of people so each bus can contain 50 people and the reamining people have to go in vans each can contain 6 people so here is the program;
//THis program will determine the number of buses needed for a tour
#include"stdafx.h"
#include <iostream.h>
void main()
{
int people, remainder, people_to_buses, vans;
int buses= 50;
cout<<"Enter the number of people?";
cin>> people;
//Calculate the buses needed
people_to_buses = people / buses;
remainder = people % buses;
//output answer
cout<<"Buses needed " <<people_to_buses<<"\n";
//calculate # of vans needed
vans=remainder/6;
//output to user
cout<<"The number of vans needed is";
cout<<vans<<"\n";
}
Where do i put the if statement and how do i write it?

What conditions do you need the if statement to check for?
David

Ok, if you just need to check for the number of vans needed for the remainder of people, then try something like this:
Code:
//calculate # of vans needed
vans=remainder/6;
// if the remainder is not 0, then execute
if ( (remainder % 6) != 0)
{
// add one more to the van count
++van; // or van+=1; or van = van + 1;
}
David