954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

what is wrong??

include <iostream>

main ()
{
int a, b;
bool found;
cout << "Enter two integers: "
cin >> a >> b;

if a > a*b && 10 < b
found = 2 * a > b;
else
{
found = 2 * a < b;
if found
a = 3;
c = 15;
if b
{
b = 0;
a = 1;
}
}
odonal01
Newbie Poster
7 posts since Jan 2009
Reputation Points: 8
Solved Threads: 0
 

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?"

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

Chris

Freaky_Chris
Master Poster
702 posts since Apr 2008
Reputation Points: 325
Solved Threads: 118
 

The basic structure should be more like

#include <iostream>
using namespace std;

int main ()
{
   // DO STUFF
  return 0;
}


Also i think your IF statement is wrong...

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

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
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.

Muhammad farhan
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

Freaky_Chris
Master Poster
702 posts since Apr 2008
Reputation Points: 325
Solved Threads: 118
 

Even when 'found' is an int, that code would be just fine

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You