First project in school using C++, need assistance

I'm doing my first project and I'm kind of in the dark on figuring out what I did wrong so if anyone can point out the issue or issues for me then that would be a HUGE help. I also realize that you are not here to do my homework for me and I'm not asking for that, I am just extremely confused on what goes where and how to get it to do certain things since this is my first experience with C++. I think that my issue is the word "result" but I'm not quite sure what I should replace it with.

When the program is finished the dialog box is suposed to say:

Input three different integers: 13 27 14
Sum is 54
Average is 18
Product is 4914
Smallest is 13
Largest is 27



My program is:

// Fig 2.19: fig02_19.cpp
// Calculate the summation, average, product, smallest, and largest of the three integers
#include <iostream> // allows program to perform input and output

using std::cout; // program uses cout
using std::cin; //program uses cin
using std ::endl; // program uses endl

// function main begins program execution
int main()
{
int number1; //first integer to compare
int number2; //second integer to compare
int number3; //third integer to compare

cout << "Input three different integers: "; // prompt user for data
cin >> number1 >> number2 >> number3; // read three integers from user

result = 1 + 2 + 3; // add the three integers; store result

result = ( 1 + 2 + 3 ) / 3; // add the three integers and then divide by three; store result

result = 1 * 2 * 3; // multiply the three integers; store result

// calculate smallest of the three integers; store result

// calculate largest of the three integers; store result

cout << "The answers are " << endl; // print results; end line

return 0; //indicate program executed successfully
} // end function main
result = 1 + 2 + 3;
This makes result equal 6 regardless of what the user enters. This is not what you're trying to do. You want result's value to be based on what the user enters. You need to use the variables you defined (number1, number2, number3). The same goes for the other two lines.

Variables can hold only one value (there are data structures that can hold more, but that's not relevant right now). If you have this code:
1
2
3
a=b+c;
a=b*c;
//line 3 
When the flow of execution reaches line 3, 'a' will have just one value: the one it was last set to.

See if you can find what's wrong with you std::cout statement yourself (most importantly, where to put it and how many times). Consider your comment which you wrote in plain English.
I'm still a little lost on what to do but I'm going to mess around with it and see if I can't figure it out. Thanks for the hints
try creating variables for each of the answers:
 
int sum,average,product,smallest,largest;


Then in your calculations:
 
sum = number1 + number2 + number3;


and the output:
 
cout << "The sum is " << sum << endl;


I'll leave the rest to you

Ok, everything is starting to make more sense now that i've been messing around with it a little more. Thanks for all of the help everyone.
Topic archived. No new replies allowed.