← Quiz: Storage Classes in C: all 15 questions
Quiz: Storage Classes in C · Question 8 of 15
Why is static int t = n 2; (inside a function, n a parameter) an error?
Why is static int t = n * 2; (inside a function, n a parameter) an error?
- A.A static variable must be initialised with a constant expression, because it is set before the program runs
- B.static variables cannot be int
- C.Parameters cannot be multiplied
- D.static variables cannot be initialised at all
Answer & explanation
Correct answer: A static variable must be initialised with a constant expression, because it is set before the program runs
Statics are initialised once, before main starts, when n has no value yet.
Can you get the rest right without peeking?
Take the timed Quiz: Storage Classes in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →