Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
94 Questions 5 Topics Take Test
Advertisement
Showing 41–50 of 94 questions
Q.41 Easy C Programming
Which of the following is a correct way to declare a pointer to an integer in C?
A int ptr*;
B int *ptr;
C int& ptr;
D *int ptr;
Correct Answer:  B. int *ptr;
Explanation:

The correct syntax for declaring a pointer to an integer is 'int *ptr;' where the asterisk (*) indicates it is a pointer variable.

Take Test
Q.42 Easy C Programming
What is the output of the following code: printf("%d", sizeof(int));
A 2 bytes
B 4 bytes
C The code will print a number (typically 4 on most systems)
D Error in compilation
Correct Answer:  C. The code will print a number (typically 4 on most systems)
Explanation:

sizeof(int) returns the size of integer in bytes as an integer value. On most modern systems, this is 4 bytes, and printf with %d will print this numeric value.

Take Test
Q.43 Easy C Programming
Which of the following correctly initializes a 2D array in C?
A int arr[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}};
B int arr[][3] = {1,2,3,4,5,6,7,8,9};
C Both A and B are correct
D Neither A nor B is correct
Correct Answer:  C. Both A and B are correct
Explanation:

Both syntaxes are valid in C. Option A explicitly specifies both dimensions, while Option B lets the compiler calculate the first dimension based on initialization.

Take Test
Q.44 Easy C Programming
Which of the following is NOT a valid identifier in C?
A _variable123
B 123_variable
C variable_123
D Variable_123
Correct Answer:  B. 123_variable
Explanation:

In C, an identifier cannot start with a digit. It must start with a letter (a-z, A-Z) or underscore (_). Option B violates this rule by starting with a digit.

Take Test
Q.45 Easy C Programming
In C, what is the difference between single quotes and double quotes?
A No difference, they are interchangeable
B Single quotes are for characters, double quotes are for strings
C Single quotes for strings, double quotes for characters
D Single quotes cannot be used in C
Correct Answer:  B. Single quotes are for characters, double quotes are for strings
Explanation:

In C, single quotes (') are used for single character constants (char type), while double quotes (") are used for string literals (array of characters ending with null terminator).

Take Test
Advertisement
Q.46 Easy C Programming
Which of the following is true about the 'break' statement in C?
A It skips the current iteration
B It exits the loop or switch statement
C It terminates the program
D It has no effect in loops
Correct Answer:  B. It exits the loop or switch statement
Explanation:

The 'break' statement is used to exit or terminate a loop or switch statement immediately. It transfers control to the statement following the loop or switch.

Take Test
Q.47 Easy C Programming
Which of the following correctly declares a 2D array in C?
A int arr[3][4];
B int arr(3,4);
C int arr;
D int arr{3,4};
Correct Answer:  A. int arr[3][4];
Explanation:

A 2D array in C is declared using the syntax: datatype arrayName[rows][columns]. So 'int arr[3][4];' creates a 2D array with 3 rows and 4 columns.

Take Test
Q.48 Easy C Programming
What will be the memory size occupied by: int arr[5][3];?
A 15 bytes
B 60 bytes
C 30 bytes
D Depends on the compiler
Correct Answer:  B. 60 bytes
Explanation:

The array has 5 rows and 3 columns, so total elements = 5 × 3 = 15 elements. Each int typically occupies 4 bytes. Total memory = 15 × 4 = 60 bytes (assuming sizeof(int) = 4 bytes on most systems).

Take Test
Q.49 Easy C Programming
Which loop construct in C guarantees execution at least once?
A while loop
B for loop
C do-while loop
D nested loop
Correct Answer:  C. do-while loop
Explanation:

The do-while loop executes the body at least once before checking the condition. The syntax is: do { statements; } while(condition);. In contrast, while and for loops check the condition first.

Take Test
Q.50 Easy C Programming
What is the scope of a variable declared inside a block?
A Global scope
B Local scope (block scope)
C Static scope
D External scope
Correct Answer:  B. Local scope (block scope)
Explanation:

Variables declared inside a block (enclosed in curly braces) have local or block scope. They are accessible only within that block and cease to exist once the block execution is complete.

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