Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 81–90 of 309 questions
Q.81 Easy C Programming
Which of the following is used to declare a constant in C?
A constant int x = 5;
B const int x = 5;
C final int x = 5;
D immutable int x = 5;
Correct Answer:  B. const int x = 5;
Explanation:

In C, the 'const' keyword is used to declare constants. Once a const variable is initialized, its value cannot be changed. Options A, C, and D are not valid C syntax.

Take Test
Q.82 Easy C Programming
What is the purpose of the return statement in a C function?
A To exit the program
B To return a value to the caller and exit the function
C To declare variables
D To create a loop
Correct Answer:  B. To return a value to the caller and exit the function
Explanation:

The return statement is used to exit a function and return a value (if any) to the calling function. If the function has return type void, no value is returned.

Take Test
Q.83 Medium C Programming
What will be the output of: int x = 5; x += 3; printf("%d", x);?
A 5
B 8
C 3
D 53
Correct Answer:  B. 8
Explanation:

The operator += means x = x + 3. So x = 5 + 3 = 8. The printf statement outputs 8.

Take Test
Q.84 Medium C Programming
Which loop in C does NOT check the condition before executing the loop body?
A for loop
B while loop
C do-while loop
D foreach loop
Correct Answer:  C. do-while loop
Explanation:

The do-while loop executes the loop body at least once before checking the condition. Other loops check the condition before execution. Syntax: do { } while(condition);

Take Test
Q.85 Medium C Programming
What will be the output of: int x = 5; int y = ++x; printf("%d %d", x, y);?
A 5 5
B 6 6
C 5 6
D 6 5
Correct Answer:  B. 6 6
Explanation:

The pre-increment operator (++x) increments x first, then assigns it. So x becomes 6, and y is assigned 6. Output: 6 6.

Take Test
Advertisement
Q.86 Medium C Programming
Which function is used to allocate memory dynamically in C?
A allocate()
B malloc()
C new()
D create()
Correct Answer:  B. malloc()
Explanation:

malloc() (memory allocation) is used to dynamically allocate memory on the heap in C. It requires #include <stdlib.h>. new() is used in C++, not C.

Take Test
Q.87 Medium C Programming
What is the output of: int a = 10, b = 20; int temp = a; a = b; b = temp; printf("%d %d", a, b);?
A 10 20
B 20 10
C 20 20
D 10 10
Correct Answer:  B. 20 10
Explanation:

This is a swap operation. Initially a=10, b=20. After temp=a (temp=10), a=b (a=20), b=temp (b=10). Output: 20 10.

Take Test
Q.88 Medium C Programming
In C, what does the scanf() function do?
A Displays output to the screen
B Reads input from standard input (keyboard)
C Creates a new variable
D Allocates memory
Correct Answer:  B. Reads input from standard input (keyboard)
Explanation:

scanf() reads formatted input from the standard input device (usually keyboard). printf() displays output. Both require #include <stdio.h>.

Take Test
Q.89 Medium C Programming
What will be the output of: for(int i = 0; i < 3; i++) { printf("%d ", i); }?
A 0 1 2
B 1 2 3
C 0 1 2 3
D 3 2 1
Correct Answer:  A. 0 1 2
Explanation:

Loop runs with i=0,1,2. When i=3, condition i<3 becomes false and loop terminates. Output: 0 1 2 (with spaces).

Take Test
Q.90 Medium C Programming
Which of the following is the correct way to define a function that takes no parameters and returns no value?
A void function() { }
B null function() { }
C empty function() { }
D void function(void) { }
Correct Answer:  A. void function() { }
Explanation:

In C, void function() { } is correct. In some contexts, void function(void) { } is more explicit. Options B and C use invalid keywords for this purpose.

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