Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 121–130 of 309 questions
Q.121 Easy C Programming
What will be the output of: int a = 5, b = 5; if(a == b) printf("Equal"); else printf("Not Equal");
A Equal
B Not Equal
C Syntax Error
D No output
Correct Answer:  A. Equal
Explanation:

The == operator compares values. Since a and b both have value 5, the condition is true and "Equal" is printed.

Take Test
Q.122 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.123 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.124 Easy C Programming
Which header file is essential for using the printf() function in C?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
Explanation:

The stdio.h header file contains declarations for standard input/output functions like printf(). Option A is C++, Option C is C++, and Option D is for memory allocation functions.

Take Test
Q.125 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
Advertisement
Q.126 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.127 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
Q.128 Medium C Programming
What will be the output of: int x = 5, y = 10; if (x < y) printf("yes"); else printf("no");
A yes
B no
C Compilation error
D No output
Correct Answer:  A. yes
Explanation:

The condition x < y evaluates to true (5 < 10), so the if block executes, printing 'yes'. The else block is skipped.

Take Test
Q.129 Medium C Programming
Which of the following is NOT a valid way to pass arguments to a function in C?
A Pass by value
B Pass by reference
C Pass by pointer
D All are valid
Correct Answer:  B. Pass by reference
Explanation:

C supports pass by value and pass by pointer/address. 'Pass by reference' as a concept exists in C++, not in C. In C, to achieve reference-like behavior, we use pointers.

Take Test
Q.130 Medium C Programming
What will be the result of: int a = 10, b = 3; int c = a % b; printf("%d", c);
A 3
B 1
C 13
D 30
Correct Answer:  B. 1
Explanation:

The modulus operator % returns the remainder of division. 10 % 3 = 1 (since 10 = 3 × 3 + 1). Therefore, c = 1 and the output is 1.

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