0
0
Cprogramming~5 mins

Variable declaration and initialization - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a variable declaration in C?
A variable declaration in C tells the computer to create a space in memory to store a value of a specific type, but it does not assign a value yet.
Click to reveal answer
beginner
What does variable initialization mean?
Variable initialization means giving a variable its first value at the time of declaration.
Click to reveal answer
beginner
How do you declare and initialize an integer variable named 'age' with the value 25 in C?
int age = 25;
Click to reveal answer
intermediate
What happens if you declare a variable but do not initialize it in C?
The variable contains a garbage value (random data) until you assign a value to it.
Click to reveal answer
intermediate
Can you declare multiple variables of the same type in one line? Give an example.
Yes. For example: int x = 5, y = 10, z = 15;
Click to reveal answer
Which of the following is a correct variable declaration and initialization in C?
Aint = 10 number;
Bnumber int = 10;
Cint number = 10;
Dint number : 10;
What value does an uninitialized local variable in C hold?
AOne
BZero
CNull
DGarbage (random) value
Which keyword is used to declare a variable in C?
Aint, float, char (data types)
Blet
Cvar
Ddeclare
How do you declare three integer variables a, b, and c in one line?
Aint a; int b; int c;
Bint a, b, c;
Cint a = b = c;
Dint a b c;
What is the correct way to initialize a character variable named letter with 'A'?
Achar letter = 'A';
Bchar letter = "A";
Cchar letter = A;
Dchar letter = (A);
Explain the difference between variable declaration and initialization in C.
Think about what happens when you tell the computer about a variable versus giving it a value.
You got /4 concepts.
    Write an example of declaring and initializing multiple variables of the same type in one line.
    Use int type and assign values to variables a, b, and c.
    You got /4 concepts.