🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.A static variable must be initialised with a constant expression, because it is set before the program runs
  2. B.static variables cannot be int
  3. C.Parameters cannot be multiplied
  4. 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 →