what am i doing wrong?

give me the error:
sh-4.3$ main
sh: main: command not found and some others.
what am i doing wrong?

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

using namespace std;

int main()
{
   int a, b, c;
   std::cout<<"please enter 3 integers";
   cin>>a>>b>>c;
   
   if(a<b && a<c){
       if(b < c) {
           cout<<a<<b<<c;
           else
           cout<<a<<c<<b;
       }
   }
 else
 if(b<c){
           cout<<b<<c<<a;
           else
           cout<<c<b<a;
           
           return 0;
       }
}
   
   
Braces does not match for both else within b<c statements.
closed account (E0p9LyTq)
You are missing more than a few enclosing braces. I don't know if the following is the logical method you want for the program, but it compiles:

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

int main()
{
   int a, b, c;
   std::cout << "please enter 3 integers: ";
   std::cin>> a >> b >> c;

   if(a < b && a < c)
   {
      if(b < c)
      {
         std::cout << a << b << c;
      }
      else
      {
         std::cout << a << c << b;
      }
   }
   else if (b < c)
   {
      std::cout << b << c << a;
   }
   else
   {
      std::cout << c << b <<a;
   }
   return 0;
}


I use braces a lot because it makes it easier to see the relationship with if/else statements.
Topic archived. No new replies allowed.