SHOW:
|
|
- or go back to the newest paste.
1 | #include <stdio.h> | |
2 | ||
3 | - | int main() /* Most important part of the program! */ |
3 | + | int main() |
4 | { | |
5 | - | int age; /* Need a variable... */ |
5 | + | int age; |
6 | ||
7 | - | printf( "Please enter your age" ); /* Asks for age */ |
7 | + | printf( "Please enter your age" ); |
8 | - | scanf( "%d", &age ); /* The input is put in age */ |
8 | + | scanf( "%d", &age ); //This will read from stdin and attempt to take the input and place it in an integer variable. |
9 | - | if ( age < 100 ) { /* If the age is less than 100 */ |
9 | + | if ( age < 100 ) { |
10 | - | printf ("You are pretty young!\n" ); /* Just to show you it works... */ |
10 | + | printf ("You are pretty young!\n" ); |
11 | } | |
12 | - | else if ( age == 100 ) { /* I use else just to show an example */ |
12 | + | else if ( age == 100 ) { |
13 | printf( "You are old\n" ); | |
14 | } | |
15 | else { | |
16 | - | printf( "You are really old\n" ); /* Executed if no other statement is */ |
16 | + | printf( "You are really old\n" ); |
17 | } | |
18 | ||
19 | - | } |
19 | + | printf("Control structure passed."); |
20 | return 0; | |
21 | } | |
22 | //Questions: | |
23 | //1) What are you using for input? | |
24 | //2) When you run this one, do you see the last printf? |