Advertisement
bhok

C++ Variables

May 25th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. /// Tutorials found on BrandonHok.com
  2. #include <iostream>
  3.  
  4. int main()
  5.  
  6. {
  7.  
  8.     // [Section 1]
  9.     // Try running this section set first. Do not add any other code yet.
  10.     // What happens when you erase std::cin.get();?
  11.     std::cout << "What do you think cout does?\n";
  12.     std::cout << "Try pressing a number now\n";
  13.     std::cin.get();
  14.  
  15.     // [Section 2]
  16.     // Add these statements now.
  17.     // We are introducing what is a variable now. Basically like in math x = o
  18.     // What is variable222?
  19.     // What happened? Do you know why?
  20.     int variable1 = 777;
  21.     int variable222;
  22.  
  23.     // [Section 3]
  24.     // What happened here? Why did the number 777 appear?
  25.     // What do you think \n does? Try erasing it and see what happens.
  26.     std::cout << variable1 << "\n";
  27.     std::cout << "End of Section 3\n";
  28.     system("pause");
  29.  
  30.     // [Section 4]
  31.     // What do you think cin do?
  32.     // What do you think cout do?
  33.     // What do you think << and >> do?
  34.     // What do you think std::endl; does? Try erasing it and see what happens.
  35.     std::cin >> variable222;
  36.     std::cout << variable222 << "\nWhat do you think cout and cin does?\n" << std::endl;
  37.     std::cout << "End of Statement 4" << std::endl;
  38.     system("pause");
  39.  
  40.     // [Statements 5]
  41.     // What do you think happened here?
  42.     // What happened to variable3 and variable4 in the beginning and end?
  43.     int variable3;
  44.     int variable4;
  45.     std::cin >> variable3 >> variable4;
  46.     std::cout << variable3 << " This is variable3" << std::endl;
  47.     std::cout << "Try a 3 digit number now" << std::endl;
  48.     std::cin >> variable3 >> variable4;
  49.     std::cout << variable3 + variable4 << std::endl;
  50.     system("pause");
  51.  
  52.     // Summarize the lesson on paper. What are the major concepts today?
  53.     // What do you think this statement does? You may want to google it and learn more about it.
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement