Need some help !

Write your question here.

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
#include <iostream>
using namespace std;

int main()
{
int a, b, c, d, e
cout<<"please enter a number";
cin>>a;
cout<<"please enter another number";
cin>>b;
cout<<"please enter the last number";
cin>>c;

d=a>b
e=b>a

if (a>c) {
cout>>"the greatest number is">>a;

else

if (c>a) {
cout>>"the greatest number is">>c;
}
}


This was in class. It prompts the user to enter 3 integer, and output which one is the greatest integer as the result. It was done on Microsoft visual C++ 10.
debugged it and 1 failed error about linkers. Turned that off and still won't compile.

am i doing something wrong? please point it out and is there other ways u can do this. thanks
Might like to check for missing semi colons in line 6,14 and 15?
Also check use of << in cout line 18 and 23
Last edited on
Here you go :)

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
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    
    cout<<"please enter a number:\t";
    cin>>a;
    cout<<"please enter another number:\t";
    cin>>b;
    cout<<"please enter the last number:\t";
    cin>>c;
    
    if(a > b && a > c)
    {
       std::cout << a << " is your biggest number.";
    }  
    if(b > a && b > c)
    {
        std::cout << b << " is your biggest number.";
    } else {
        
       if(c > a && a > b)
        {
            std::cout << c << " is your biggest number.";
        }         
    }
}
thanks alot.
i thought of using max. does it work in this case? if it does, how would you put it.
Yes you can! try this.

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>

using namespace std;

int checkNumber(int x, int max)
{
    if(x > max)
    {
        cout << "This is too high!";
        
        return false;
    }
    
    return true;
}

int main()
{
    bool pass;
    int a, b, c;
    const int MAX_NUM = 100;
    
    cout<<"please enter a max number of " << MAX_NUM<< ":\t";
    cin>>a;
    pass = checkNumber(a,MAX_NUM);
    if(pass == false)
    {
        return -1;
    }
    cout<<"please enter another max number of " << MAX_NUM<< ":\t";
    cin>>b;
    pass = checkNumber(a,MAX_NUM);
    if(pass == false)
    {
        return -1;
    }
    cout<<"please enter the last max number of " << MAX_NUM<< ":\t";
    cin>>c;
    pass = checkNumber(a,MAX_NUM);
    if(pass == false)
    {
        return -1;
    }
    
    if(a > b && a > c)
    {
       std::cout << a << " is your biggest number.";
    }  
    if(b > a && b > c)
    {
        std::cout << b << " is your biggest number.";
    } else {
        
       if(c > a && a > b)
        {
            std::cout << c << " is your biggest number.";
        }         
    }
}
lol. i think thats more complicated for my level. BUT THANKS alot!~
Topic archived. No new replies allowed.