Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 31–40 of 309 questions
Q.31 Easy 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.32 Easy 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.33 Medium 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.34 Medium 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.35 Medium 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.36 Medium 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.37 Medium 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.38 Medium 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.39 Medium 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.40 Medium 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
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