Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- // Here is our first if statements
- // Let's see how it works
- // Try typing in the code below
- // What do you think will happen?
- // Do you see the differences in the code below? Explain what do you see
- // Code Section 1
- int pancakes = 5;
- if (pancakes > 4)
- std::cout << "We need to eat more pancakes! \n" ;
- // ***If needed, include and delete system pause on where needed
- // system("pause");
- // Code Section 2
- // Now copy the code below try an if...else statement
- // Now, what if we change the 5 to a 2?
- // What happens if we remove the {} for the second expression?
- int pancakesArea2 = 5;
- if (pancakesArea2 > 4)
- std::cout << "We need to eat more pancakes! \n";
- if (pancakesArea2 < 3)
- {
- std::cout << "WHOA! WE NEED MORE PANCAKES! START THE ENGINES! \n";
- }
- // Code Section 3
- // What happens if we included an else statement. What do you think will happen?
- int pancakesPies = 5;
- if (pancakesPies > 4)
- std::cout << "We need to eat more pancakes!";
- else
- {
- std::cout << "WHOA! WE NEED MORE PANCAKES! START THE ENGINES!";
- }
- // Code Section 4
- // Try changing the numbers and getting all three responses
- int pancakesMonsters = 5;
- if (pancakesMonsters >= 4)
- std::cout << "We need to eat more pancakes!";
- else if (pancakesMonsters == 10)
- std::cout << "WHOA! WE NEED MORE PANCAKES! START THE ENGINES!";
- else
- std::cout << "What just happened?";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement