Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
94 Questions 5 Topics Take Test
Advertisement
Showing 31–40 of 94 questions
Q.31 Easy C Programming
What does the sizeof() operator return?
A The address of a variable
B The number of bytes occupied by a data type or variable
C The maximum value a variable can hold
D The number of bits in a variable
Correct Answer:  B. The number of bytes occupied by a data type or variable
Explanation:

sizeof() is a unary operator that returns the number of bytes occupied by a variable or data type in memory.

Take Test
Q.32 Easy C Programming
Which of the following is a correct way to initialize a 1D array in C?
A int arr[5] = {1, 2, 3, 4, 5};
B int arr[] = {1, 2, 3, 4, 5};
C int arr[5];
D All of the above
Correct Answer:  D. All of the above
Explanation:

All three methods are valid. Option A initializes with size 5, option B auto-determines size from initialization, and option C declares without initialization.

Take Test
Q.33 Easy C Programming
What is the size of an empty structure in C?
A 0 bytes
B 1 byte
C 4 bytes
D 8 bytes
Correct Answer:  B. 1 byte
Explanation:

An empty structure in C has a size of 1 byte. This is to ensure each structure instance has a unique address in memory.

Take Test
Q.34 Easy C Programming
What will be the output of: char *s = "Hello"; printf("%d", strlen(s));
A 5
B 6
C 4
D Error
Correct Answer:  A. 5
Explanation:

strlen() counts characters excluding the null terminator. "Hello" has 5 characters, so strlen(s) returns 5.

Take Test
Q.35 Easy C Programming
What will be the output of: #define MAX 10; int x = MAX; printf("%d", x);
A 10
B Error
C MAX
D Undefined
Correct Answer:  A. 10
Explanation:

The #define directive replaces MAX with 10 during preprocessing. So x = 10 and output is 10. (Note: semicolon after MAX is not needed but doesn't affect the output)

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

Both syntaxes are correct. C allows initializing 2D arrays with or without explicit braces for each row.

Take Test
Q.37 Easy C Programming
What will be the output of: printf("%d", 5/2);
A 2.5
B 2
C 3
D 2.0
Correct Answer:  B. 2
Explanation:

Integer division truncates the decimal part. 5/2 = 2 (not 2.5) because both operands are integers.

Take Test
Q.38 Easy C Programming
What does the getchar() function do?
A Reads a single character from input
B Reads a string from input
C Displays a character
D Returns ASCII value of a character
Correct Answer:  A. Reads a single character from input
Explanation:

getchar() reads a single character from standard input (stdin) and returns its ASCII value.

Take Test
Q.39 Easy C Programming
What will be the output of: int a = 5, b = 5; if(a == b) printf("Equal"); else printf("Not Equal");
A Equal
B Not Equal
C Syntax Error
D No output
Correct Answer:  A. Equal
Explanation:

The == operator compares values. Since a and b both have value 5, the condition is true and "Equal" is printed.

Take Test
Q.40 Easy C Programming
Which header file is essential for using the printf() function in C?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
Explanation:

The stdio.h header file contains declarations for standard input/output functions like printf(). Option A is C++, Option C is C++, and Option D is for memory allocation functions.

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