If a is greater than b then if a is greater than 300 multiply a by 7. Otherwise— in case a is not greater
than b—multiply a by 10.
Use only two if and one else. Make sure your else is paired with the correct if. You may have to
use { }

``````#include <iostream>
using namespace std;
int main ()
int a, int b
{
if (a > b)
if (a > 300)
a*7
else
b > a
b*10``````

Does that look right else if statements confuse me.

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by Lokril

you need to go back to your notes. this is all wrong.

That comes across as very rude.

Use braces to tell you which ifs and elses match up (when the if statement only has one line of code following it, you technically don't need them, but it should help you see where your errors are)

``````if(something)
{
if(something)
{

}
}
else
{

}``````

etc.

The statements `a*7` and `b*10` don't do anything by themselves. You may want to reread your text to see some examples where something is assigned to another variable.

If you want a to equal a times 7 then write a = a*7. not just a*7

Ok I don't have my notes but I looked it up a little and this is what I got how am I doing?

{
if(a > 300)
return (a)*7;
}

if (a > b)
return (a) * 7
else
(a < b)
return (b)*100;
}

never mind the code i don't get the question. what if b=150 and a=299?
this is starting to look like a car crash.

Edited by frogboy77: n/a

how am I doing?

You're attempting to return the results now, but to what? To the operating system? That's where the return value from main() goes.

This is one of those times where you're going to have to sit down and do it with pencil and paper and turn it into code afterwards. Read exactly what the instructions are telling you, and write it out.

Sorry I should of clarified this is a test question and I only need to write out the function the rest is supposed to be a given.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.