ProgrammingHardStatement-count style · Product-company MCQ pattern
How many of these are correct in C? (i) A global variable without an initialiser starts as 0. (ii) A static local variable is initialised only once. (iii) An uninitialised auto local variable starts as 0. (iv) The address of a register variable can be taken with &.
- A. Only one
- B. Only two
- C. Only three
- D. All four
Correct answer: B. Only two
(i) true: objects with static storage duration are zero-initialised. (ii) true. (iii) false: an auto local holds an indeterminate value. (iv) false: C forbids & on a register variable (C++ allows it). So two.
More C Programming questions
- What is f in the declaration int (f)(int); ?
- What is printed? c int a[] = {5, 10, 15}; int p = a; int x = p++; int y = (p)++; int z = ++p; printf("%d %d %d %d", x, y, z, a[1]);
- With 32-bit unsigned int, what is printed? c unsigned int x = 0; x--; printf("%u %d", x, x > 0);
- With ASCII and 4-byte int, what is printed? c char c = 'A'; c = c + 32; printf("%c %zu", c, sizeof(c + 1));
- What is printed? c char s[] = "abcdef"; char p = s, q = s + strlen(s) - 1; while (p < q) p++ = q--; printf("%s", s);
- What is printed? c struct A { int a[2]; }; struct B { int p; }; int v = 5; struct A x = {{1, 2}}, y; struct B m = {&v}, n; y = x; n = m…