Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
65 Questions 5 Topics Take Test
Advertisement
Showing 21–30 of 65 questions
Q.21 Hard C Programming
In C, when passing arrays to functions, what is actually passed?
A A copy of all array elements
B The address of the first element (pointer)
C The array size
D All array elements and size
Correct Answer:  B. The address of the first element (pointer)
Explanation:

When an array is passed to a function in C, it decays to a pointer pointing to the first element. This is why changes made in the function affect the original array.

Take Test
Q.22 Hard C Programming
What will be the output of: int a = 5; int *p = &a; printf("%d %d", a, *p);?
A 5 garbage value
B 5 5
C address address
D 0 5
Correct Answer:  B. 5 5
Explanation:

p is a pointer storing the address of a. *p (dereferencing) gives the value at that address, which is 5. So both a and *p print 5.

Take Test
Q.23 Hard C Programming
What does the static keyword do when used with a global variable?
A Makes it accessible only within the same file
B Makes it a constant
C Increases its memory allocation
D Makes it thread-safe
Correct Answer:  A. Makes it accessible only within the same file
Explanation:

When static is used with a global variable, it restricts its scope to the file where it is declared. Without static, global variables are accessible across files using extern.

Take Test
Q.24 Hard C Programming
Consider: int arr[10]; int *p = arr; What is p[5] equivalent to?
A &arr[5]
B *arr + 5
C *(arr + 5) or arr[5]
D Cannot be determined
Correct Answer:  C. *(arr + 5) or arr[5]
Explanation:

Array name decays to pointer. p[5] is equivalent to *(p+5) which is *(arr+5) or arr[5]. This demonstrates pointer arithmetic.

Take Test
Q.25 Hard C Programming
What is the difference between declaration and definition in C?
A They are the same thing
B Declaration informs compiler about type, definition allocates memory
C Definition comes before declaration
D Declaration is only for functions
Correct Answer:  B. Declaration informs compiler about type, definition allocates memory
Explanation:

Declaration tells the compiler about a variable's name and type (e.g., 'extern int x;'). Definition actually allocates memory (e.g., 'int x = 5;'). A variable can be declared multiple times but defined only once.

Take Test
Advertisement
Q.26 Hard C Programming
What will be the output of: int x = 10; int y = x++ + ++x; printf("%d", y);
A 20
B 21
C 22
D 23
Correct Answer:  B. 21
Explanation:

x++ returns 10 and increments x to 11. ++x increments x to 12 and returns 12. So y = 10 + 12 = 22. Wait, let me recalculate: y = 10 + 11 = 21 (as x becomes 11 after first post-increment, then ++x makes it 12).

Take Test
Q.27 Hard C Programming
Consider a complex expression: int x = 2 + 3 * 4 - 5 / 2; What is x?
A 6
B 13
C 11
D 12
Correct Answer:  B. 13
Explanation:

Following operator precedence: 3*4=12, 5/2=2 (integer division), 2+12=14, 14-2=12. Actually x = 2 + 12 - 2 = 12. Let me recalculate: 2 + (3*4) - (5/2) = 2 + 12 - 2 = 12. Wait: 2 + 12 - 2 = 12, not 13. The answer should be D.

Take Test
Q.28 Hard C Programming
What happens if you declare a variable but don't initialize it in C?
A Compilation error
B It contains garbage value
C It is automatically initialized to 0
D The program crashes
Correct Answer:  B. It contains garbage value
Explanation:

Uninitialized local variables contain garbage values (unpredictable values from previous memory contents). Global and static variables are automatically initialized to 0, but local variables are not.

Take Test
Q.29 Hard C Programming
Consider: int *ptr = NULL; *ptr = 5; What will happen?
A 5 is stored at NULL address
B Segmentation fault/Access violation
C Compilation error
D No error, value is lost
Correct Answer:  B. Segmentation fault/Access violation
Explanation:

Attempting to dereference a NULL pointer causes undefined behavior, typically resulting in a segmentation fault (runtime error). A NULL pointer doesn't point to valid memory.

Take Test
Q.30 Hard C Programming
What does the 'volatile' keyword indicate in C?
A The variable can be modified externally at any time
B The variable cannot be modified
C The variable is stored in a register
D The variable has global scope
Correct Answer:  A. The variable can be modified externally at any time
Explanation:

The volatile keyword tells the compiler that a variable's value may change unexpectedly (e.g., due to hardware, interrupts, or other threads), preventing compiler optimizations that assume the value doesn't change.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips