what is wrong??

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 6
Reputation: odonal01 is an unknown quantity at this point 
Solved Threads: 0
odonal01 odonal01 is offline Offline
Newbie Poster

what is wrong??

 
0
  #1
Feb 2nd, 2009
  1. include <iostream>
  2.  
  3. main ()
  4. {
  5. int a, b;
  6. bool found;
  7. cout << "Enter two integers: "
  8. cin >> a >> b;
  9.  
  10. if a > a*b && 10 < b
  11. found = 2 * a > b;
  12. else
  13. {
  14. found = 2 * a < b;
  15. if found
  16. a = 3;
  17. c = 15;
  18. if b
  19. {
  20. b = 0;
  21. a = 1;
  22. }
  23. }
Last edited by Ancient Dragon; Feb 2nd, 2009 at 10:00 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: what is wrong??

 
0
  #2
Feb 2nd, 2009
Well for one, you didn't use code tags. When you post code, you should put it in code tags:
[ code=cplusplus]
// Your C++ Code Here
[ /code]

Secondly, your main function doesn't seem to return an int, or take command line parameters...
Third, you aren't using namespace std;, which is a problem, since you try to use cout and cin...
Fourth, your include is missing the #...
Hell, I guess the topic (and question) should be "what isn't wrong?"
Last edited by Comatose; Feb 2nd, 2009 at 8:24 pm. Reason: fixing code tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: what is wrong??

 
1
  #3
Feb 2nd, 2009
Read the forum rules, read a C++ book, read previous threads, just read something!

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,221
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 538
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: what is wrong??

 
0
  #4
Feb 2nd, 2009
The basic structure should be more like

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. // DO STUFF
  7. return 0;
  8. }

Also i think your IF statement is wrong...
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1
Reputation: Muhammad farhan is an unknown quantity at this point 
Solved Threads: 0
Muhammad farhan Muhammad farhan is offline Offline
Newbie Poster

Re: what is wrong??

 
0
  #5
Feb 3rd, 2009
YOUNG MAN THE WAY YOU USES IF STATEMENT IS JUST ROUGH YOU NEED PARENTHESIS FOR IS STATEMENT {MENTIONING UR MISAKES IN CAPITAL FORMAT)
FOR EXAMPLE

include <iostream>
main ()
{
int a, b;
INT bool found;
cout << "Enter two integers:
"cin >> a >> b;
if (a > a*b && 10 < b) I INTRODUCED THESE PARENTHESIS
found = 2 * a > b;
else
{
found = 2 * a < b;
if found (NO CONDITION APPLIED)E.G. IF (FOUND==0)
a = 3;
c = 15;
if b (AGAIN NO CONDITION APPLIED)
{
b = 0;a = 1;
}
}



IM SORRY BUT U NEED LOT OF PRACTICE.
KEEP WORKING HARD.
BEST OF LUCK.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: what is wrong??

 
0
  #6
Feb 3rd, 2009
Muhammad so do you, firstly you havn't used code tags, secondly comments '//' * '/* */' are useful for commenting code.

When found is a bool, then if(found) is fine.

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,879
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: what is wrong??

 
0
  #7
Feb 3rd, 2009
Even when 'found' is an int, that code would be just fine
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC