Home Tests Campus Placement Computer Knowledge

Campus Placement
Computer Knowledge

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

309 Q 4 Subjects Any Graduate
Take Mock Test
Difficulty: All Easy Medium Hard 271–280 of 309
Advertisement
Q.271 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.272 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
Q.273 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.274 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.275 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
Advertisement
Q.276 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.277 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
Q.278 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.279 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.280 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
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