home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1690
Discussions: 188,402, Posts: 2,243,609, Members: 232,632
Old April 8th, 2005, 11:31 PM   Digg it!   #1 (permalink)
Senior Member
 
Arenal's Avatar
 
Join Date: Mar 2005
Location: oklahoma, US
Posts: 557
Send a message via AIM to Arenal Send a message via Yahoo to Arenal
If statements??

i do not get If statements at all in C++,
i use them like it says to and i get errors
let me show you

Code:
#include <iostream>

using namespace std;

int main()
{
    if (5<4);
       Execute the next statement;
    {cout<<"HEY I UNDERSTAND IF's!!";}
    cin.get();
}
__________________
RIP TKOP!!

Arenal is offline   Reply With Quote
Old April 8th, 2005, 11:41 PM     #2 (permalink)
Ultimate Member
 
erhan28's Avatar
 
Join Date: Aug 2004
Location: SouthWest, Florida
Posts: 1,440
Send a message via MSN to erhan28 Send a message via Yahoo to erhan28
What is the (count<< part ??
other than that it seem fine, is this is , i mean there has to be an output how will you show the result.
__________________
MSI K8N Neo4 Platinum / A64X2 4800+ Toledo(Stock)
7900GTX 698mhz / 2GB Corsairs XMS PRO Dual
Hitachi SATA II (2x 250GB, 1x 500GB)
ASUS G1

erhan28 is offline   Reply With Quote
Old April 8th, 2005, 11:43 PM     #3 (permalink)
Senior Member
 
Arenal's Avatar
 
Join Date: Mar 2005
Location: oklahoma, US
Posts: 557
Send a message via AIM to Arenal Send a message via Yahoo to Arenal
(cout is changed but i dont know what you mean by

"i mean there has to be an output how will you show the result.
"

Arenal is offline   Reply With Quote
Old April 8th, 2005, 11:46 PM     #4 (permalink)
Ultimate Member
 
erhan28's Avatar
 
Join Date: Aug 2004
Location: SouthWest, Florida
Posts: 1,440
Send a message via MSN to erhan28 Send a message via Yahoo to erhan28
You said if 5<4. What is greater than 4? This cant be the complete code. and the output i mean, how are you going to show the "hey I know if statements". like in java its
system.out"BLAHBLAHBLAH"
erhan28 is offline   Reply With Quote
Old April 8th, 2005, 11:50 PM     #5 (permalink)
Senior Member
 
Arenal's Avatar
 
Join Date: Mar 2005
Location: oklahoma, US
Posts: 557
Send a message via AIM to Arenal Send a message via Yahoo to Arenal
with iostream, it shows it on command prompt, and why would you need something greater than 4, it shouldn't show the cout b/c it's false
Arenal is offline   Reply With Quote
Old April 8th, 2005, 11:54 PM     #6 (permalink)
Ultimate Member
 
erhan28's Avatar
 
Join Date: Aug 2004
Location: SouthWest, Florida
Posts: 1,440
Send a message via MSN to erhan28 Send a message via Yahoo to erhan28
oh ok,
you need an else or it will do nothing if the number is lees than 4.
I would show you an example but i forgot a lot about java, and java is simalar to c++.
yea try an else statement and write like "NOTTRUEBLAH" or anyother message to see if it is working.

Edit:
Some time I would script a program and keep getting errors because the program i use to type it f**ed up. SO I copy/ pasted on a new program with the exact same code and it worked, so try that too.
erhan28 is offline   Reply With Quote
Old April 9th, 2005, 12:02 AM     #7 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
In Java a simple if statement would be like:

Code:
If (intNum < 4){
  //Process code here
  //intNum is less than 4
}
Else If (intNum > 6){
  //Sample Else If
  //intNum is greater than 6
}
Else{
  //Sample Else code
  //intNum is either 4, 5 or 6
}
I’m sure it’s very similar to C++.


-Blaze

Last edited by Blazer06 : April 9th, 2005 at 12:05 AM.
Blazer06 is offline   Reply With Quote
Old April 9th, 2005, 12:05 AM     #8 (permalink)
Ultimate Member
 
FatalException's Avatar
 
Join Date: Jun 2004
Location: Indianapolis, Indiana
Posts: 1,386
You included a semicolon after the if statement:

if(4<5);
{
statements
}

You can't have that semicolon ( ; ) there.

A proper C++ if statement:
Code:
#include <iostream.h>

int main(void)
{
   int number=5;
   if(number<10)
   {
       cout << "The statement is true!\n";
   }
   return 0;
}
__________________
Logic shall prevail.
FatalException is offline   Reply With Quote
Old April 9th, 2005, 12:06 AM     #9 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
I don’t program C++, but what if you changed your if statement to this:

Code:
int main()
{
  if (5 < 4){
    //Execute the next statement;
    cout<<"HEY I UNDERSTAND IF's!!";
    cin.get();
  }
}

-Blaze
Blazer06 is offline   Reply With Quote
Old April 9th, 2005, 12:07 AM     #10 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
Quote:
Originally Posted by FatalException
You included a semicolon after the if statement:

if(4<5);
{
statements
}

You can't have that semicolon ( ; ) there.
That’s what I was thinking, but wasn’t sure if it was (which it is) the same as in Java.

Also, for reference, a simple Google showed this:
http://msdn.microsoft.com/library/en...m/statem_9.asp


-Blaze
Blazer06 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL statements in a loop Tekk Webmastering and Programming 1 September 22nd, 2004 08:32 PM
House Report: 237 Misleading statements on Iraq MTAtech IMO Community 3 March 21st, 2004 08:08 PM
Pete Rose and Sorry Statements of the Third Kind Theophylact IMO Community 2 January 13th, 2004 08:51 PM
Advice or recommendation for software dealing with Business plans/financal statements DRat Applications and Operating Systems 1 September 26th, 2002 01:41 AM

Most Active Discussions
Is It Just Me? (2906)
3-days in and no threads about Gaza (161)
Misery Loves Company... (2144)
New Build ( Finally ) (7)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
RCA 52Inch HDTV wont turn on (5)
Folderchat Weekday thread (444)
Recent Discussions
Futronix has water features? (0)
Laptop proccesor to desktop mob.. (2)
Please help! multiple problems! (4)
RCA 52Inch HDTV wont turn on (5)
New Build ( Finally ) (7)
Common Spyware Solutions (97)
How do you move a hard-drive to.. (4)
What is the best external enclo.. (0)
Partition Magic 7.0 (Unallocate.. (17)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 04:45 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28