cplusplus:selection_examples
Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
cplusplus:selection_examples [2013/02/03 01:57] – created mithat | cplusplus:selection_examples [2013/02/03 02:50] – mithat | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== if ===== | ===== if ===== | ||
- | <file c++ if_example.cpp># | + | <file c++ if_example.cpp> |
+ | #include < | ||
using namespace std; | using namespace std; | ||
Line 20: | Line 21: | ||
===== if/else ===== | ===== if/else ===== | ||
+ | <file c++ if_else_example.cpp>/ | ||
+ | #include < | ||
+ | using namespace std; | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | int num1; | ||
+ | cout << "Enter an integer, and I will tell you "; | ||
+ | cout << "if the number is positive: "; | ||
+ | cin >> num1; // read an integer | ||
+ | |||
+ | if (num1 > 0) | ||
+ | cout << num1 << " is positive. "<< | ||
+ | else | ||
+ | cout << num1 << " is not positive. "<< | ||
+ | |||
+ | return 0; | ||
+ | }</ | ||
===== Nested if/else ===== | ===== Nested if/else ===== | ||
cplusplus/selection_examples.txt · Last modified: 2013/02/11 01:00 by mithat