943,822 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 396
  • C++ RSS
Feb 2nd, 2009
0

what is wrong??

Expand Post »
C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 8
Solved Threads: 0
Newbie Poster
odonal01 is offline Offline
7 posts
since Jan 2009
Feb 2nd, 2009
0

Re: what is wrong??

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
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 2nd, 2009
1

Re: what is wrong??

Read the forum rules, read a C++ book, read previous threads, just read something!

Chris
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Feb 2nd, 2009
0

Re: what is wrong??

The basic structure should be more like

C++ Syntax (Toggle Plain Text)
  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...
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,510 posts
since Apr 2005
Feb 3rd, 2009
0

Re: what is wrong??

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Muhammad farhan is offline Offline
1 posts
since Jan 2009
Feb 3rd, 2009
0

Re: what is wrong??

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
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Feb 3rd, 2009
0

Re: what is wrong??

Even when 'found' is an int, that code would be just fine
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Having a hard time inputting a line of text into a char array
Next Thread in C++ Forum Timeline: Need help with writing a balance program.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC