Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
150 Questions 5 Topics Take Test
Advertisement
Showing 51–60 of 150 questions
Q.51 Medium C Programming
What will be the output of the following code?
int a = 5;
int b = ++a + a++;
printf("%d", b);
A 11
B 12
C 10
D 13
Correct Answer:  B. 12
Explanation:

++a increments a to 6 and returns 6. Then a++ returns 6 and increments a to 7. So b = 6 + 6 = 12.

Take Test
Q.52 Medium C Programming
What will be the output of: int x = 5; printf("%d", x
A 5
B 10
C 20
D 2
Correct Answer:  B. 10
Explanation:

The left shift operator (<<) shifts bits to the left by 1 position, which is equivalent to multiplying by 2. So 5 << 1 = 10.

Take Test
Q.53 Medium C Programming
Consider the code: int arr[10]; int *p = arr; What is p[5]?
A Address of arr[5]
B Value at arr[5]
C 5th element after arr
D Garbage value
Correct Answer:  B. Value at arr[5]
Explanation:

p points to arr, so p[5] is equivalent to *(p+5) which gives the value at arr[5].

Take Test
Q.54 Medium C Programming
What is the purpose of the void pointer in C?
A To store addresses of any data type
B To declare functions with no return
C To declare variables with no value
D All of the above
Correct Answer:  D. All of the above
Explanation:

The void pointer is a generic pointer that can hold addresses of any data type. void is also used for functions returning nothing and parameters.

Take Test
Q.55 Medium C Programming
Which function is used to read a string from standard input?
A gets()
B fgets()
C scanf()
D All of the above
Correct Answer:  D. All of the above
Explanation:

All three functions can read strings, though gets() is deprecated due to security issues. fgets() is safer as it limits input size.

Take Test
Advertisement
Q.56 Medium C Programming
What is the output of: int arr[] = {1,2,3,4,5}; printf("%d", sizeof(arr)/sizeof(arr[0]));
A 5
B 20
C 4
D Depends on compiler
Correct Answer:  A. 5
Explanation:

sizeof(arr) gives total size of array. sizeof(arr[0]) gives size of one element. Dividing gives the number of elements: 20/4 = 5.

Take Test
Q.57 Medium C Programming
What will be the output of: char c = 'A'; printf("%d", c);
A 65
B A
C Error
D 1
Correct Answer:  A. 65
Explanation:

The %d format specifier prints the ASCII value of the character. 'A' has ASCII value 65.

Take Test
Q.58 Medium C Programming
What is the output of: int arr[5]; printf("%d", sizeof(arr));
A 5
B 10
C 20
D 1
Correct Answer:  C. 20
Explanation:

sizeof(arr) returns the total size of the array in bytes. An array of 5 integers, where each int is 4 bytes, equals 5 × 4 = 20 bytes.

Take Test
Q.59 Medium C Programming
Which function is used to allocate memory dynamically at runtime?
A alloc()
B malloc()
C memalloc()
D allocate()
Correct Answer:  B. malloc()
Explanation:

malloc() is the standard C library function for dynamic memory allocation. It returns a void pointer to the allocated memory block, which can be cast to the required data type.

Take Test
Q.60 Medium C Programming
What is the purpose of the break statement in a switch case?
A To exit the program
B To exit the current loop or switch
C To skip the next statement
D To pause execution
Correct Answer:  B. To exit the current loop or switch
Explanation:

The break statement terminates the current loop or switch block and transfers control to the statement following the loop or switch. Without it, execution continues to the next case (fall-through).

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