Video

Key Takeways

Video Addendum

Assignment

  • Work through the memory tables for both of your past assignments from Lesson01.
  • For each of the code samples below:
    1. DO NOT RUN THE CODE YET
    2. Work through the memory table.
    3. Write what your program is doing in a sentence.
    4. Write what you think the program will output in console.
    5. Run the code in a new Repl to check your memory tables & outputs.
  • Create a new Repl where you request 2 numbers from the user, and then display their sum.

Code Samples

Sample 0
#include <iostream>

int main() {
  int first = 100;
  int second = 2450;
  float third = 100.0;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;

  first = first + second * 2;
  second = second + 50;
  third = third / second;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;
  
  first = second / first;
  third = first / third;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;
}
Sample 1
#include <iostream>

int main() {
  std::cout << "Enter a number: ";
  int first = 100;
  
  std::cin >> first;
  int second = 2450;
  float third = 100.0;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;

  first = first + second * 2;
  second = second + 50;
  third = third / second;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;
  
  first = second / first;
  third = first / third;
  std::cout << "First number is: " << first << std::endl;
  std::cout << "Second number is: " << second << std::endl;
  std::cout << "Third number is: " << third << std::endl;
}


End of Assignment Checklist

  • I finished all the assignments.
  • I shared my assignments with others.
  • I provided feedback for assignments of at least 2 others.
  • I addressed the feedback from others and thanked them for the review.