New here, 'Hi' to all.
I'm, starting a Software Engineering degree at Uni this October and so am trying to teach myself C++ in preparation.
Anyway.
I'm writing this programme to find the average of 3 numbers.
PHP Code:
#include <iostream>
using namespace std;
int main()
{
int numberone,numbertwo,numberthree,numberaverage;
cout<<"Please enter the first number: ";
cin>> numberone;
cin.ignore();
cout<<"Please enter the second number: ";
cin>> numbertwo;
cin.ignore();
cout<<"Please enter the third number: ";
cin>> numberthree;
cin.ignore();
numberaverage = numberone + numbertwo + numberthree / 3;
cout <<"The average is " <<numberaverage;
cin.get();
Everything is working fine apart from this line:-
PHP Code:
numberaverage = numberone + numbertwo + numberthree / 3;
It is supposed to divide the sum total of the 3 integers/variables by 3 to give the average, but it is not.
For example 10 + 20 + 30 is giving 40 as the answer, not 20.
What should I be doing?
Thanks very much!
Swerve