Feb 24, 2012 at 2:10pm UTC
I have an assignment and I know I'm missing something but i'm not sure what it is.
I have to add cin but i'm not sure where.
this is my program.
{
// Declare the sum of three numbers
int num1 = 125;
int num2 = 28;
int num3 = -25;
int sum = 0;
// Start processing here
sum =(num1 + num2 + num3);
// The output here
cout << " The Sum of Three Numbers is " << sum << endl;
return 0;
Feb 24, 2012 at 2:15pm UTC
What do you mean you have to add cin? Why? Your program as posted (assuming you have brackets sorted, int main in there etc...) declares 3 ints and adds them together.
Why do you need to use cin?
Feb 24, 2012 at 2:24pm UTC
Maybe you wanted to say that values of the variables should be entered from cin? If so you could write
// Declare the sum of three numbers
int num1, num2, num3;
int sum;
// Start processing here
cout << "Enter num1, num2, num3: ";
cin >> num1 >> num2 >> num3;
sum = num1 + num2 + num3;
// The output here
cout << " The Sum of Three Numbers is " << sum << endl;
return 0;
Last edited on Feb 24, 2012 at 2:25pm UTC