Q&A Notes: Variables, Input, and Output

Table of Contents


Answer these questions in a text document and upload to Canvas. Answer with whatever programming language you'd like.


1. Data types

  • What is a string data type?
  • What is an integer data type?
  • What is a float data type?
  • What is a boolean data type?

2. Assignment statements (=)

  • What symbol is the assignment operator?
  • What does "RHS" and "LHS" stand for?
  • What form does an assignment statement take?
  • Assigning a variable to a literal value - Write out a statement to create a variable named pet_name and assign it a value "Luna".
  • Copying one variable's value to another variable - Write out a statement to create a variable named best_pet and assign it the value from pet_name.

3. Input statements (input, cin)

  • Inputting a string - Write an input statement asking the user to enter their pet's name and store it in a string pet_name.
  • Inputting an integer - Write an input statement asking the user to enter their pet's age and store it in an integer pet_age.

4. Output statements (print, cout)

  • Outputting a string literal - Write an output statement to display the text "Pet name:" to the screen.
  • Outputting a variable value - Write an output statement to display the value of the variable pet_name to the screen.

Author: Rachel Wil Sha Singh

Created: 2023-09-13 Wed 21:57

Validate