What's the problem here?

09/25/2012 10:10 CantShutMyMouth#1
Hello guys. what is the problem here?

PHP Code:

#include <iostream>
using namespace std;

int main()

{
    
int a,b,c,d,x;
    
cout<<"Numarul a:";
    
cin>>a;
    
cout<<"Numarul b:";
    
cin>>b;
    (
c=a+b);
    (
d=a*b);

    if(
c>d)
        (
x=c);
        (
c=d);
        (
d=x);
        
cout<<"d este";
        
cout<<d;
        
cout<<"c este";
        
cout<<c;
    else
        
cout<<"d este";
        
cout<<d;
        
cout<<"c este";
        
cout<<c;





    if(
a!=0)
        
cout<<"d este";
        
cout<<d;
        
cout<<"c este";
        
cout<<c;
    else
        
cout<<"d este";
        
cout<<d;
        
cout<<"c este";
        
cout<<c;






C:\MinGWStudio\Templates\T1\Andrei2.cpp||In function 'int main()':|
C:\MinGWStudio\Templates\T1\Andrei2.cpp|23|error: 'else' without a previous 'if'|
C:\MinGWStudio\Templates\T1\Andrei2.cpp|38|error: 'else' without a previous 'if'|
||=== Build finished: 2 errors, 0 warnings ===|
09/25/2012 10:18 getFamous#2
Hi,

i think if you use if and hafe more then one option in there you have to use brackets. then you have to return 0! so main knows all is ok
if my code doesnt work pls answer .. at the moment i havent access to compile my code

greets

Code:
#include <iostream>
using namespace std;

int main()
{
    int a,b,c,d,x;
    cout<<"Numarul a:";
    cin>>a;
    cout<<"Numarul b:";
    cin>>b;
    (c=a+b);
    (d=a*b);

    if(c>d)
       {
        (x=c);
        (c=d);
        (d=x);
        cout<<"d este";
        cout<<d;
        cout<<"c este";
        cout<<c;
      }
    else
     {
        cout<<"d este";
        cout<<d;
        cout<<"c este";
        cout<<c;
       }





    if(a!=0)
       {
        cout<<"d este";
        cout<<d;
        cout<<"c este";
        cout<<c;
        }
    else
        {
        cout<<"d este";
        cout<<d;
        cout<<"c este";
        cout<<c;
       }
    
 return 0

}
09/25/2012 10:31 CantShutMyMouth#3
It worked. Thanks alot
09/30/2012 16:50 Fawkess123#4
For the explanation functions every function but void need a raturn value ^^
09/30/2012 19:12 dasschild#5
Quote:
Originally Posted by Fawkess123 View Post
For the explanation functions every function but void need a raturn value ^^
That's true,but as far I can remember for the Entrypoint there is no need for a return value in visual studio. The main problem was that the body tags '{' and '}' are missing to mark where the if and the else condition block is starting and ending.