Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 101–110 of 309 questions
Q.101 Medium C Programming
What is the difference between calloc() and malloc()?
A calloc() initializes memory to zero, malloc() does not
B malloc() is faster than calloc()
C calloc() takes two arguments, malloc() takes one
D All of the above
Correct Answer:  D. All of the above
Explanation:

calloc(n, size) allocates n blocks of size bytes and initializes to 0. malloc(size) allocates size bytes without initialization. calloc() is typically slower due to initialization.

Take Test
Q.102 Medium C Programming
Which of the following is used to comment multiple lines in C?
A // comment
B /* comment */
C # comment
D -- comment
Correct Answer:  B. /* comment */
Explanation:

/* */ is used for multi-line comments in C. // is used for single-line comments and was introduced in C99.

Take Test
Q.103 Medium C Programming
What will be the output of: float x = 5/2; printf("%f", x);
A 2.500000
B 2.000000
C 2.5
D Compilation Error
Correct Answer:  B. 2.000000
Explanation:

Since both 5 and 2 are integers, integer division occurs (5/2 = 2). The result 2 is then converted to float as 2.000000.

Take Test
Q.104 Medium C Programming
How are structures different from unions in C?
A Structures allocate separate memory for each member, unions share memory
B Unions allocate separate memory for each member, structures share memory
C There is no difference
D Structures are faster than unions
Correct Answer:  A. Structures allocate separate memory for each member, unions share memory
Explanation:

In structures, each member has its own memory location. In unions, all members share the same memory location, so only one can hold a value at a time.

Take Test
Q.105 Hard C Programming
What does the static keyword do when used with a global variable?
A Makes it accessible only within the same file
B Makes it a constant
C Increases its memory allocation
D Makes it thread-safe
Correct Answer:  A. Makes it accessible only within the same file
Explanation:

When static is used with a global variable, it restricts its scope to the file where it is declared. Without static, global variables are accessible across files using extern.

Take Test
Advertisement
Q.106 Hard C Programming
Consider: int arr[10]; int *p = arr; What is p[5] equivalent to?
A &arr[5]
B *arr + 5
C *(arr + 5) or arr[5]
D Cannot be determined
Correct Answer:  C. *(arr + 5) or arr[5]
Explanation:

Array name decays to pointer. p[5] is equivalent to *(p+5) which is *(arr+5) or arr[5]. This demonstrates pointer arithmetic.

Take Test
Q.107 Hard C Programming
What is the difference between declaration and definition in C?
A They are the same thing
B Declaration informs compiler about type, definition allocates memory
C Definition comes before declaration
D Declaration is only for functions
Correct Answer:  B. Declaration informs compiler about type, definition allocates memory
Explanation:

Declaration tells the compiler about a variable's name and type (e.g., 'extern int x;'). Definition actually allocates memory (e.g., 'int x = 5;'). A variable can be declared multiple times but defined only once.

Take Test
Q.108 Medium C Programming
What will be the output of the following code?
int a = 5;
int b = ++a + a++;
printf("%d", b);
A 11
B 12
C 10
D 13
Correct Answer:  B. 12
Explanation:

++a increments a to 6 and returns 6. Then a++ returns 6 and increments a to 7. So b = 6 + 6 = 12.

Take Test
Q.109 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.110 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
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