My Program is not Working

I'm not sure why my program can't work. Can you help me fix it and improve it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>

using namespace std;

int main()
{
    int height;
    cout<<"Please enter how tall you are in feet.\nPlease round your height to the nearest foot.\nInput your height to continue:";
    cin>>height;
    cin.ignore();
    if (height<=2) {
        cout<<"Wow! You are extremely short! Congrats for lying about your height!\n";
    }
    if (height=3) {
        cout<<"You are pretty short!\n";
    }
    if (height=4) {
        cout<<"You are pretty short!\n";
    }
    if (height=5) {
        cout<<"You have an average height! Congrats!\n";
    }
    if (height=6) {
        cout<<"You have an average height! Congrats!\n";
    }
    if (height=7) {
        cout<<"You are pretty tall!\n";
    }
    if (height=8) {
        cout<<"You are pretty tall!\n";
    }
    if (height>=9) {
        cout<<"Wow! You are extremely tall! Congrats for lying about your height!\n";
    }
}
'=' is make equal to

'==' is to check if something is equal.

So use == for checking equality and = for setting equality.

if (height == 5)
{

etc...

Should work then.

You also do not need cin.ignore() and you should put 'return 0;' at the end of your main. It is also usual to make statements like this 'else if' after the first if statement, so the computer does not have to go through and check all the if statements unnecessarily.
Thx! It did work!
Topic archived. No new replies allowed.