Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 03:41

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



What's the problem here?

Discussion on What's the problem here? within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
CantShutMyMouth's Avatar
 
elite*gold: 0
Join Date: Apr 2012
Posts: 380
Received Thanks: 163
What's the problem here?

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 ===|
CantShutMyMouth is offline  
Old 09/25/2012, 10:18   #2
 
getFamous's Avatar
 
elite*gold: 4
Join Date: Aug 2012
Posts: 130
Received Thanks: 38
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

}
getFamous is offline  
Thanks
1 User
Old 09/25/2012, 10:31   #3
 
CantShutMyMouth's Avatar
 
elite*gold: 0
Join Date: Apr 2012
Posts: 380
Received Thanks: 163
It worked. Thanks alot
CantShutMyMouth is offline  
Old 09/30/2012, 16:50   #4
 
elite*gold: 0
Join Date: Dec 2011
Posts: 5
Received Thanks: 1
For the explanation functions every function but void need a raturn value ^^
Fawkess123 is offline  
Old 09/30/2012, 19:12   #5
 
elite*gold: 0
Join Date: Jun 2009
Posts: 132
Received Thanks: 37
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.
dasschild is offline  
Reply


Similar Threads Similar Threads
[Problem]Habe ein Problem und zwar spinnt mein VPC etwas(ohne Grund)?!
07/28/2011 - Metin2 Private Server - 10 Replies
Also wie schon gesagt meins Server spinnt wodurch kiks usw. kommen :( ich lade euch die Screens in den Anhang, mit der Hoffnung, dass ihr mir helfen könnt :) wäre echt sehr nice :)



All times are GMT +1. The time now is 03:41.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.