cplusplus:selection_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
cplusplus:selection_examples [2013/02/03 02:50] – mithat | cplusplus:selection_examples [2013/02/03 02:53] – mithat | ||
---|---|---|---|
Line 21: | Line 21: | ||
===== if/else ===== | ===== if/else ===== | ||
+ | |||
<file c++ if_else_example.cpp>/ | <file c++ if_else_example.cpp>/ | ||
#include < | #include < | ||
Line 41: | Line 42: | ||
- | ===== Nested | + | ===== nested |
+ | |||
+ | <file c++ nested_if_else_example.cpp>/ | ||
+ | #include < | ||
+ | using namespace std; | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | int grade; | ||
+ | cout << "Enter a numerical grade, and I will tell you" << endl; | ||
+ | cout << "how well the student performed: "; | ||
+ | cin >> grade; | ||
+ | |||
+ | cout << "The student received a letter grade of "; | ||
+ | if ( grade >= 90 ) | ||
+ | cout << " | ||
+ | else if ( grade >= 80 ) | ||
+ | cout << " | ||
+ | else if ( grade >= 70 ) | ||
+ | cout << " | ||
+ | else if ( grade >= 60 ) | ||
+ | cout << " | ||
+ | else | ||
+ | cout << " | ||
+ | cout << " | ||
+ | |||
+ | return 0; | ||
+ | }</ | ||
cplusplus/selection_examples.txt · Last modified: 2013/02/11 01:00 by mithat