Variables

In this section, we’ll dive into variables in C. A variable is a storage container for data that is capable of holding different values that may change or update as programs execute. Your program can read the contents of a variable, update the contents of a variable, and display the value of a variable on the screen. Computer programs can use variables in order to remember useful information that the programs can then use later in the code.

  • Lecture

  • Shorts

  • Notes

  • Submit your answers & your program to CANVAS as a variables.c file

    • Why do we need variables?
    • What would happen to our programs if we couldn’t use variables?
    • If we didn’t have access to variables, how would this affect your program?
  • Write a program that:

    • novice coder: create a program that adds two numbers together given by a user
    • comfy coder: create a program that finds the average of three positive numbers given by a user
    • l33t coder: create a program that finds the square of a number given by a user
    • neo: create a program that when two numbers are given the output results in a swap of values

      • Output of program:
      • Enter two integers
      • 23
      • 45
      • Before Swapping
      • First integer = 23
      • Second integer = 45
      • After Swapping
      • First integer = 45
      • Second integer = 23