Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 91–100 of 309 questions
Q.91 Medium C Programming
What is the output of the following program: int x = 5; if(x > 3) printf("Greater"); else printf("Smaller");?
A Smaller
B Greater
C 5
D Error
Correct Answer:  B. Greater
Explanation:

x=5 is greater than 3, so the condition (x > 3) evaluates to true. The if block executes, printing 'Greater'.

Take Test
Q.92 Hard C Programming
In C, when passing arrays to functions, what is actually passed?
A A copy of all array elements
B The address of the first element (pointer)
C The array size
D All array elements and size
Correct Answer:  B. The address of the first element (pointer)
Explanation:

When an array is passed to a function in C, it decays to a pointer pointing to the first element. This is why changes made in the function affect the original array.

Take Test
Q.93 Hard C Programming
What will be the output of: int a = 5; int *p = &a; printf("%d %d", a, *p);?
A 5 garbage value
B 5 5
C address address
D 0 5
Correct Answer:  B. 5 5
Explanation:

p is a pointer storing the address of a. *p (dereferencing) gives the value at that address, which is 5. So both a and *p print 5.

Take Test
Q.94 Easy C Programming
Which header file is required for using the printf() function?
A cstdlib.h
B stdio.h
C string.h
D math.h
Correct Answer:  B. stdio.h
Explanation:

stdio.h (Standard Input/Output header) contains declarations for printf(), scanf(), and other I/O functions.

Take Test
Q.95 Easy C Programming
What is the correct syntax to declare a constant in C?
A const int x = 10;
B int const x = 10;
C constant int x = 10;
D Both A and B
Correct Answer:  D. Both A and B
Explanation:

Both 'const int x = 10;' and 'int const x = 10;' are valid ways to declare constants in C. The const keyword can appear before or after the type.

Take Test
Advertisement
Q.96 Easy C Programming
Which operator is used to access the value at an address in C?
A &
B *
C ->
D .
Correct Answer:  B. *
Explanation:

The * operator is the dereference operator that accesses the value at a memory address. The & operator gets the address of a variable.

Take Test
Q.97 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.98 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.99 Medium C Programming
What is the return type of the malloc() function?
A int
B void*
C char*
D null
Correct Answer:  B. void*
Explanation:

malloc() returns a void pointer (void*) which can be cast to any pointer type. It returns NULL if memory allocation fails.

Take Test
Q.100 Medium C Programming
Which function is used to release dynamically allocated memory in C?
A delete()
B free()
C release()
D dealloc()
Correct Answer:  B. free()
Explanation:

The free() function deallocates memory that was previously allocated using malloc(), calloc(), or realloc(). delete() is used in C++.

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