Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 111–120 of 309 questions
Q.111 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.112 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.113 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.114 Easy C Programming
What will be the output of: #define MAX 10; int x = MAX; printf("%d", x);
A 10
B Error
C MAX
D Undefined
Correct Answer:  A. 10
Explanation:

The #define directive replaces MAX with 10 during preprocessing. So x = 10 and output is 10. (Note: semicolon after MAX is not needed but doesn't affect the output)

Take Test
Q.115 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.116 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.117 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.118 Easy C Programming
Which of the following correctly initializes a 2D array?
A int arr[3][3] = {1,2,3,4,5,6,7,8,9};
B int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
C Both A and B
D Neither A nor B
Correct Answer:  C. Both A and B
Explanation:

Both syntaxes are correct. C allows initializing 2D arrays with or without explicit braces for each row.

Take Test
Q.119 Easy C Programming
What will be the output of: printf("%d", 5/2);
A 2.5
B 2
C 3
D 2.0
Correct Answer:  B. 2
Explanation:

Integer division truncates the decimal part. 5/2 = 2 (not 2.5) because both operands are integers.

Take Test
Q.120 Easy C Programming
What does the getchar() function do?
A Reads a single character from input
B Reads a string from input
C Displays a character
D Returns ASCII value of a character
Correct Answer:  A. Reads a single character from input
Explanation:

getchar() reads a single character from standard input (stdin) and returns its ASCII value.

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