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 2101–2110 of 2,162
Advertisement
Q.2101 Medium Computer Knowledge C Programming
What is the output of: int x = 10; printf("%d", x++); printf("%d", x);
A 1010
B 1011
C 910
D 111
Correct Answer:  B. 1011
EXPLANATION

x++ is post-increment. First printf uses current value (10), then x is incremented. Second printf uses new value (11). Output: 1011

Take Test
Q.2102 Hard Computer Knowledge C Programming
What happens when you try to access an array element beyond its size in C?
A Compilation error
B Runtime error with exception
C Undefined behavior
D Returns 0 automatically
Correct Answer:  C. Undefined behavior
EXPLANATION

C does not perform bounds checking on arrays. Accessing beyond array bounds results in undefined behavior - it may access garbage values, crash, or seem to work without error. This is a common source of bugs.

Take Test
Q.2103 Medium Computer Knowledge C Programming
What is the output of the following code?
for(int i = 1; i
A 1 2 3
B 1 3
C 2 3
D 1
Correct Answer:  B. 1 3
EXPLANATION

When i = 1, it prints 1. When i = 2, continue skips the printf() and moves to the next iteration. When i = 3, it prints 3. Output: 1 3

Take Test
Q.2104 Medium Computer Knowledge C Programming
Consider the following code:
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
What is the value of *(ptr + 2)?
A 1
B 2
C 3
D 4
Correct Answer:  C. 3
EXPLANATION

ptr points to arr[0]. ptr + 2 points to arr[2]. *(ptr + 2) dereferences to get the value at arr[2], which is 3. Pointer arithmetic moves by the size of the data type (integers).

Take Test
Q.2105 Medium Computer Knowledge C Programming
What is the correct syntax to open a file in C?
A FILE *fp = fopen("file.txt", "r");
B FILE fp = open("file.txt", "r");
C fopen *fp = FILE("file.txt", "r");
D FILE fp = fopen("file.txt");
Correct Answer:  A. FILE *fp = fopen("file.txt", "r");
EXPLANATION

The correct syntax is FILE *fp = fopen("filename", "mode");. fopen() returns a pointer to a FILE structure, and the mode string specifies how to open the file ("r" for read, "w" for write, etc.).

Take Test
Advertisement
Q.2106 Easy Computer Knowledge C Programming
What will be the value of x after: int x = 5; x += 3;
A 3
B 5
C 8
D 53
Correct Answer:  C. 8
EXPLANATION

The += operator is a compound assignment operator. x += 3 is equivalent to x = x + 3. Therefore, 5 + 3 = 8.

Take Test
Q.2107 Medium Computer Knowledge C Programming
What is the difference between calloc() and malloc() in C?
A calloc() initializes memory to 0, malloc() does not
B malloc() is faster than calloc()
C calloc() takes two arguments, malloc() takes one
D All of the above
Correct Answer:  D. All of the above
EXPLANATION

calloc() allocates memory and initializes all bytes to 0, takes (number of elements, size of each element). malloc() just allocates memory without initialization and takes total size. calloc() is slightly slower due to initialization.

Take Test
Q.2108 Easy Computer Knowledge C Programming
How many times will the loop execute?
for(int i = 0; i < 5; i++)
A 4 times
B 5 times
C 6 times
D Infinite times
Correct Answer:  B. 5 times
EXPLANATION

The loop initializes i to 0 and continues while i < 5. Values of i: 0, 1, 2, 3, 4. After i becomes 5, the condition is false, so the loop executes 5 times.

Take Test
Q.2109 Medium Computer Knowledge C Programming
What is the scope of a variable declared inside a function in C?
A Global scope
B Local/Function scope
C Static scope
D External scope
Correct Answer:  B. Local/Function scope
EXPLANATION

Variables declared inside a function have local scope (also called function scope). They are only accessible within that function and are destroyed when the function returns.

Take Test
Q.2110 Easy Computer Knowledge C Programming
What is the output of sizeof(char) in C?
A 0 bytes
B 1 byte
C 2 bytes
D Varies by compiler
Correct Answer:  B. 1 byte
EXPLANATION

By the C standard, sizeof(char) is always 1 byte. A char is the smallest addressable unit in C and is defined to be 1 byte.

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