If Statements

I need help with these If statements they are not compiling , I want a message saying its greater than 0 to be an output when first number multiplied by the second number is greater than 0 then a second if statement with a message saying that if the third number entered is bigger than the first number entered than a message to appear saying so.And if both don’t apply then a third if statement which says a message saying that none are true test.

Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 cout << "Please Enter The first integer: ";
     cin >> numb1; 

     cout << "Please Enter The second integer: "; 
     cin >> numb2; 

	 cout << "Please Enter The third integer: "; 
     cin >> numb3; 
     sum = numb1 * numb2 
		
     if (sum >  0)
		 cout << "Sum is greater than 0 "<<sum <<endl;

	 else if (numb3 > numb1)
		 cout <<"numb3 is greater than numb1" << numb3<< endl;
	

	if ((sum > 0) || (numb3 < numb1))
	{
		cout <<"No test are true" <<endl;
Last edited on
THIS MIGHT WORK

cout << "Please Enter The first integer: ";
cin >> numb1;

cout << "Please Enter The second integer: ";
cin >> numb2;

cout << "Please Enter The third integer: ";
cin >> numb3;
sum = numb1 * numb2;

if (sum > 0)
cout << "Sum is greater than 0 "<<sum <<endl;

if (numb3 > numb1)
cout <<"numb3 is greater than numb1" << numb3<< endl;


else if ((sum < 0) || (numb3 < numb1))
cout <<"No test are true" <<endl;



BUT I DONT UNDERSTAND WHY HAVE YOU TAKEN THE VARIABLE NAME AS sum WHILE YOU ARE ACTUALLY MULTIPLYING TWO VARIABLES IN LINE NO 9
Last edited on
Maybe it's a compiler problem? I'd also suggest organizing and indenting everything properly for easier readability. Also shouldn't you change line 18 to if((sum>0) && (numb3 <numb1))?

On a side note, when you're asking about a basic concept such as an if/else statement, you should post in the beginners' section of this forum.
closed account (Dy7SLyTq)
line nine: your missing a semi colon
closed account (N36fSL3A)
koppaka wrote:
THIS MIGHT WORK

cout << "Please Enter The first integer: ";
cin >> numb1;

cout << "Please Enter The second integer: ";
cin >> numb2;

cout << "Please Enter The third integer: ";
cin >> numb3;
sum = numb1 * numb2;

if (sum > 0)
cout << "Sum is greater than 0 "<<sum <<endl;

if (numb3 > numb1)
cout <<"numb3 is greater than numb1" << numb3<< endl;


else if ((sum < 0) || (numb3 < numb1))
cout <<"No test are true" <<endl;


BUT I DONT UNDERSTAND WHY HAVE YOU TAKEN THE VARIABLE NAME AS sum WHILE YOU ARE ACTUALLY MULTIPLYING TWO VARIABLES IN LINE NO 9
Is it so hard not to write every word in caps?
Topic archived. No new replies allowed.