0
0
C++programming~5 mins

Why variables are needed in C++ - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is a variable in programming?
A variable is a name that stores a value in the computer's memory. It helps us keep and use data while the program runs.
Click to reveal answer
beginner
Why do we need variables instead of just using numbers directly?
Variables let us store values that can change or be reused. This makes programs flexible and easier to read and update.
Click to reveal answer
beginner
How do variables help when you want to do math with changing numbers?
Variables hold the numbers so you can update them or use them in calculations without rewriting the whole program.
Click to reveal answer
beginner
What happens if you don’t use variables and want to change a value in your program?
You would have to change every place the value appears, which is slow and error-prone. Variables let you change the value once.
Click to reveal answer
beginner
Can variables store different types of data? Give an example.
Yes, variables can store numbers, text, or other data types. For example, an int variable stores whole numbers, and a string variable stores words.
Click to reveal answer
What is the main reason to use variables in a program?
ATo make the program look colorful
BTo make the program run faster
CTo avoid writing code
DTo store and reuse values that can change
If you want to add two numbers that might change, what should you use?
AVariables to hold the numbers
BOnly fixed numbers in the code
CComments
DFunctions without variables
What happens if you don’t use variables and want to update a value used many times?
AThe program crashes
BYou must change every instance manually
CThe value cannot be changed
DThe program updates automatically
Which of these can a variable store?
ABoth numbers and text
BText
CNumbers
DNone of the above
Why is using variables better than using fixed numbers everywhere?
AIt uses more memory
BIt makes the program slower
CIt makes the program easier to update and understand
DIt hides the code
Explain in your own words why variables are important in programming.
Think about how you would keep track of changing information in a program.
You got /4 concepts.
    Describe a real-life example where using a variable in a program would be helpful.
    Imagine you are keeping score in a game or tracking temperature.
    You got /4 concepts.