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 2121–2130 of 2,162
Advertisement
Q.2121 Hard Computer Knowledge C Programming
Consider a pointer ptr pointing to an integer array. What does ptr[2] represent?
A The address of the third element
B The value of the third element
C The pointer itself
D The size of the array
Correct Answer:  B. The value of the third element
EXPLANATION

ptr[2] is equivalent to *(ptr+2), which dereferences the pointer and returns the value at the third element (index 2).

Take Test
Q.2122 Hard Computer Knowledge C Programming
What will be the output of: int x = 5; printf("%d", ++x);?
A 5
B 6
C 7
D Undefined
Correct Answer:  B. 6
EXPLANATION

The pre-increment operator (++x) increments x from 5 to 6 before using its value in printf(). So the output is 6.

Take Test
Q.2123 Medium Computer Knowledge C Programming
What is the correct way to declare a function that takes no parameters and returns an integer?
A int func();
B int func(void);
C func() returns int;
D int func(no parameters);
Correct Answer:  B. int func(void);
EXPLANATION

To explicitly declare a function with no parameters in C, use 'void' as the parameter. int func(); is ambiguous in older C standards.

Take Test
Q.2124 Medium Computer Knowledge C Programming
In C, what is the purpose of the #define directive?
A To define functions
B To define macros or constants
C To declare variables
D To include header files
Correct Answer:  B. To define macros or constants
EXPLANATION

#define is a preprocessor directive used to define symbolic constants (macros) and performs text substitution before compilation.

Take Test
Q.2125 Medium Computer Knowledge C Programming
Which of the following is used to access members of a structure using a pointer?
A Dot operator (.)
B Arrow operator (->)
C Ampersand (&)
D Asterisk (*)
Correct Answer:  B. Arrow operator (->)
EXPLANATION

The arrow operator (->) is used to access structure members through a pointer. The dot operator (.) is used for direct access.

Take Test
Advertisement
Q.2126 Medium Computer Knowledge C Programming
What does the break statement do in a loop?
A Skips the current iteration
B Terminates the loop immediately
C Pauses the loop
D Restarts the loop
Correct Answer:  B. Terminates the loop immediately
EXPLANATION

The break statement immediately terminates the loop and transfers control to the statement following the loop.

Take Test
Q.2127 Medium Computer Knowledge C Programming
What is the default return type of a function in C if not explicitly specified?
A void
B int
C char
D float
Correct Answer:  B. int
EXPLANATION

In C, if a function's return type is not explicitly specified, it defaults to int. However, modern C standards require explicit return type declaration.

Take Test
Q.2128 Medium Computer Knowledge C Programming
Which of the following correctly initializes an array of 5 integers?
A int arr[5] = {1, 2, 3, 4, 5};
B int arr(5) = {1, 2, 3, 4, 5};
C int [5] arr = {1, 2, 3, 4, 5};
D int arr[5];
Correct Answer:  A. int arr[5] = {1, 2, 3, 4, 5};
EXPLANATION

Arrays in C are declared with square brackets containing the size, followed by initialization in curly braces. Option A is the correct syntax.

Take Test
Q.2129 Medium Computer Knowledge C Programming
What is the purpose of the malloc() function in C?
A To deallocate memory
B To allocate memory dynamically at runtime
C To initialize variables
D To declare arrays
Correct Answer:  B. To allocate memory dynamically at runtime
EXPLANATION

malloc() (memory allocation) allocates a block of memory dynamically during program execution and returns a pointer to it.

Take Test
Q.2130 Medium Computer Knowledge C Programming
In C, a pointer variable stores which of the following?
A The actual value of a variable
B The memory address of a variable
C The size of a variable
D The data type of a variable
Correct Answer:  B. The memory address of a variable
EXPLANATION

A pointer is a variable that stores the memory address of another variable. It is declared using the * symbol.

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