Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
150 Questions 5 Topics Take Test
Advertisement
Showing 71–80 of 150 questions
Q.71 Medium C Programming
Which of the following operators has the highest precedence in C?
A * (multiplication)
B ++ (increment)
C + (addition)
D = (assignment)
Correct Answer:  B. ++ (increment)
Explanation:

The increment (++) and decrement (--) operators have the highest precedence among all operators in C, followed by unary operators, then multiplicative, additive, and so on.

Take Test
Q.72 Medium C Programming
What will be printed: int i = 0; while(i < 3) { printf("%d ", i); i++; }
A 0 1 2
B 1 2 3
C 0 1 2 3
D Nothing is printed
Correct Answer:  A. 0 1 2
Explanation:

The while loop starts with i=0. It prints 0, then increments i to 1, prints 1, increments to 2, prints 2, increments to 3, and the condition i<3 becomes false, so the loop terminates. Output: 0 1 2

Take Test
Q.73 Medium C Programming
What is the correct syntax to free dynamically allocated memory in C?
A delete ptr;
B free(ptr);
C release(ptr);
D dealloc(ptr);
Correct Answer:  B. free(ptr);
Explanation:

The free() function is used to deallocate memory that was previously allocated using malloc(), calloc(), or realloc(). This prevents memory leaks.

Take Test
Q.74 Medium C Programming
What does the following code do: int *ptr = NULL;
A Declares ptr but leaves it uninitialized
B Declares ptr and initializes it to NULL (no memory address)
C Causes a compilation error
D Allocates memory for ptr
Correct Answer:  B. Declares ptr and initializes it to NULL (no memory address)
Explanation:

This declaration creates a pointer to an integer and initializes it to NULL, which means it doesn't point to any valid memory address. This is a safe initialization practice.

Take Test
Q.75 Medium C Programming
What is the output of: printf("%f", 5/2);
A 2.5
B 2.000000
C 2
D Error
Correct Answer:  B. 2.000000
Explanation:

Since both 5 and 2 are integers, integer division is performed: 5/2 = 2. The %f format specifier then prints this integer value (2) as a floating-point number: 2.000000

Take Test
Advertisement
Q.76 Medium C Programming
What does the sizeof() operator return in C?
A The value of a variable
B The memory size in bytes of a data type or variable
C The number of elements in an array
D A boolean true/false value
Correct Answer:  B. The memory size in bytes of a data type or variable
Explanation:

The sizeof() operator returns the size in bytes of a data type or variable. For example, sizeof(int) typically returns 4 on most 32-bit systems.

Take Test
Q.77 Medium C Programming
What does the modulus operator (%) return when applied to negative numbers?
A Always positive result
B The remainder with the sign of dividend
C The remainder with the sign of divisor
D Zero
Correct Answer:  B. The remainder with the sign of dividend
Explanation:

In C, the modulus operator (%) returns a remainder that has the same sign as the dividend. For example, -7 % 3 = -1 (not 2), because -7 is the dividend and it's negative.

Take Test
Q.78 Medium C Programming
Which of the following statements about pointers is correct?
A A pointer stores the value of a variable
B A pointer stores the memory address of a variable
C A pointer can only point to integers
D Pointers cannot be modified after declaration
Correct Answer:  B. A pointer stores the memory address of a variable
Explanation:

A pointer is a variable that stores the memory address of another variable. You can access the value at that address using the dereference operator (*), and pointers can point to any data type.

Take Test
Q.79 Medium C Programming
What is the correct way to declare a constant in C?
A constant int x = 10;
B const int x = 10;
C int const x = 10;
D Both B and C
Correct Answer:  D. Both B and C
Explanation:

Both 'const int x = 10;' and 'int const x = 10;' are valid ways to declare a constant in C. The const keyword can be placed before or after the type specifier, and both have the same meaning.

Take Test
Q.80 Medium C Programming
How many times will the following loop execute: for(int i=0; i
A 2 times
B 3 times
C 4 times
D 5 times
Correct Answer:  B. 3 times
Explanation:

The loop executes for i=0, i=1, and i=2. When i=3, the break statement is encountered, which immediately terminates the loop. Therefore, the loop executes exactly 3 times.

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