Home Tests Campus Placement

Campus Placement

Campus placement MCQ questions — Aptitude, Verbal, Reasoning, Technical.

2,162 Q 4 Subjects Any Graduate
Take Mock Test
Difficulty: All Easy Medium Hard 2131–2140 of 2,162
Advertisement
Q.2131 Easy Computer Knowledge C Programming
Which operator has the highest precedence in C?
A Addition (+)
B Multiplication (*)
C Parentheses ()
D Logical AND (&&)
Correct Answer:  C. Parentheses ()
EXPLANATION

Parentheses () have the highest precedence among all operators in C. They are always evaluated first in any expression.

Take Test
Q.2132 Easy Computer Knowledge C Programming
What is the return type of the strlen() function?
A void
B char
C int
D float
Correct Answer:  C. int
EXPLANATION

The strlen() function returns the length of a string as an int value, representing the number of characters.

Take Test
Q.2133 Easy Computer Knowledge C Programming
Which of the following is a valid variable name in C?
A 2var
B _variable
C var-name
D var name
Correct Answer:  B. _variable
EXPLANATION

Variable names in C must start with a letter or underscore, not a digit. _variable is valid. '2var' starts with digit, 'var-name' contains hyphen (invalid), 'var name' contains space (invalid).

Take Test
Q.2134 Easy Computer Knowledge C Programming
Which header file is required to use 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() and scanf().

Take Test
Q.2135 Hard Computer Knowledge C Programming
What is the difference between struct and union in C?
A struct members share memory, union members have separate memory
B union members share memory, struct members have separate memory
C No difference in memory allocation
D struct is faster than union
Correct Answer:  B. union members share memory, struct members have separate memory
EXPLANATION

In a struct, each member has its own memory allocation, so the total size is the sum of all members. In a union, all members share the same memory location, so the size equals the largest member. Only one member can hold a value at a time in a union.

Take Test
Advertisement
Q.2136 Hard Computer Knowledge C Programming
What is the output of the following C code?
#define MAX 5
int main() {
int arr[MAX];
printf("%d", sizeof(arr)/sizeof(arr[0]));
return 0;
}
A Compilation error
B 5
C 20
D 4
Correct Answer:  B. 5
EXPLANATION
Step 1: sizeof(arr) = 5 × sizeof(int) = 20 bytes (assuming 4-byte int). Step 2: sizeof(arr[0]) = sizeof(int) = 4 bytes. Step 3: 20 ÷ 4 = 5. This calculates the number of elements in the array.
Take Test
Q.2137 Hard Computer Knowledge C Programming
Consider the following C code. What will be printed?
int arr[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}};
int *ptr = (int *)arr;
printf("%d", *(ptr + 5));
A 5
B 6
C 8
D 9
Correct Answer:  B. 6
EXPLANATION

A 2D array is stored in row-major order in memory: 1,2,3,4,5,6,7,8,9. When ptr is cast to int*, ptr+5 points to the 6th element (0-indexed), which is 6.

Take Test
Q.2138 Hard Computer Knowledge C Programming
What is the correct way to declare a constant pointer to a constant integer?
A const int * const ptr;
B const int const *ptr;
C int const * const ptr;
D Both A and C
Correct Answer:  D. Both A and C
EXPLANATION

Both declarations are equivalent. 'const int * const ptr' and 'int const * const ptr' declare a constant pointer to a constant integer. The first const makes the integer constant, the second const makes the pointer constant.

Take Test
Q.2139 Hard Computer Knowledge C Programming
What is the output of the following C code?
#include
int main() {
int a = 5;
printf("%d %d %d", a++, ++a, a);
return 0;
}
A 5 7 7
B 6 7 7
C 5 6 6
D Undefined behavior
Correct Answer:  D. Undefined behavior
EXPLANATION

This code contains undefined behavior because variable 'a' is modified multiple times (a++, ++a) without intervening sequence points in the same expression. The order of evaluation is unspecified, making the result compiler-dependent.

Take Test
Q.2140 Medium Computer Knowledge C Programming
What will be the output of the following C code?
int x = 10;
int y = 20;
int z = x < y ? x++ : y++;
printf("%d %d %d", x, y, z);
A 10 20 10
B 11 20 10
C 10 21 20
D 11 21 10
Correct Answer:  B. 11 20 10
EXPLANATION
Step 1: Evaluate condition x < y → 10 < 20 → true. Step 2: Execute true branch: x++ returns 10, then x becomes 11. Step 3: z = 10. Step 4: printf prints x=11, y=20, z=10.
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