game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.

TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT

 NEWS
 TECHNICAL TUTORIALS
 WEB TUTORIALS
 IMAGE EDITING
 3D MODELING
 PROJECTS
 DEMOS
 ARTICLES
 COMMUNITY

 ```#include #include using namespace std; int main() { int value=0; cout << "How many cars do you have?"; //Question? cin >> value; //Input Value //This is a if else test if(value > 0) // if Value more than 0 { cout << "Ok.." << endl; // Thats OK! } else // else value is less or equal to 0 { cout << "So you don't have a car." << endl; // then no car } // if test if(value < 0) { cout << "And you have a loan.." << endl; //if the value is negative } // if test if(value == 1) // if the value = 1 { cout << "You have a car!" << endl; } // This is called an in-line if test, with no brackets '{}'. if(value == 2) cout << "You have two cars!" << endl; // if value = 2 // You can also write an if in one line like this // more than 3 cars shuld make you rich if(value > 3 ) cout << "Are you rich?" << endl; getchar(); // wait for a key to be pressed return 0; } // The IF statement is the first thing i learned in programming. // IF? is your questions to the application, so that you can // decide what is going to happen next.. // if a counter is 10 then set it back to 0 // if you don't have any money left, you can't buy that dvd-player. // if your character fall more than 3 meters in a game, // then he loses energy etc. //sometimes you just need one if statement // // if (?) // { // // } //sometimes you ned two or more if statements // // if (question1?) // { // // } // // if (question2?) // { // // } //sometimes it is easier to use if else // // if(?) // { // // } // else // { // // } //sometimes it is easier to use if else if // if(question1?) // { // // } // else if(question2?) // { // // } // I have tried to demonstrate different ways to write if tests // It all depend on the "situation", and how you prefer to do your programming.. ```

 I hope you found this c++ tutorial useful! Don't forget to mention Apron Tutorials in your References! Best Regards Ronny André Reierstad