Welcome Guest [Log In] [Register]



Add Reply
Lesson Part IV (C++); Lession 4 (if statment)
Topic Started: Aug 25 2006, 04:54 PM (518 Views)
fsd
3a4

Code:
 
#include <iostream>

using namespace std;

int main() {
 int x = 3;
 int y = 4;

cout << "what does x equal" << endl;
cin >> x;

cout << "what does y equal" << endl;
cin >> y;

 if (x > y) {
   cout << "x is bigger than y" << endl;
 }
 else {
   cout << "x is smaller than y" << endl;
 }
 system("pause");
 return 0;
}


int x = 3;
----------define your variables
int y = 4;

cout << "what does x equal" << endl;
cin >> x ;
--------------------------------------------get the values
cout << "what does y equal" << endl;
cin >> y ;

if (x > y) - you start with your if statment then inside the () you put the condition and then we do {} in this you put what to do if (condition)

else - the else statment this you can put after a if stament just in case the condition if false
"mmmmm i love the internet. every time i go to a website i get a cookie HOW AWESOME IS THAT!" - Quote from me


"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - Albert Einstein
"Imagination is more important than knowledge."- Albert Einstein
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Tutorials · Next Topic »
Add Reply


Theme designed by Sith of Outline