Central Exam — Computer Knowledge
UPSC · SSC · Bank · Railway · NDA — Central Government Exam MCQ Practice
309 Questions 5 Topics Take Test
Advertisement
Showing 171–180 of 309 questions
Q.171 Easy C Programming
Which of the following is NOT a valid variable name in C?
A _myVar
B myVar123
C 123myVar
D my_var
Correct Answer:  C. 123myVar
Explanation:

Variable names in C cannot start with a digit. They must begin with a letter (a-z, A-Z) or underscore (_). '123myVar' is invalid.

Take Test
Q.172 Easy C Programming
What will be the output of: printf("%d", 5 + 3 * 2);?
A 16
B 11
C 13
D 18
Correct Answer:  B. 11
Explanation:

Operator precedence: multiplication (*) is performed before addition (+). So: 3 * 2 = 6, then 5 + 6 = 11.

Take Test
Q.173 Easy C Programming
What keyword is used to create a pointer variable in C?
A ref
B *
C &
D ptr
Correct Answer:  B. *
Explanation:

The asterisk (*) symbol is used to declare pointer variables. For example: int *ptr; declares a pointer to an integer.

Take Test
Q.174 Medium C Programming
What is the correct syntax to pass a 2D array to a function in C?
A func(int arr[][])
B func(int arr[rows][cols])
C func(int arr[][cols])
D func(int **arr)
Correct Answer:  C. func(int arr[][cols])
Explanation:

When passing a 2D array to a function, the number of columns must be specified, but the number of rows is optional. Option C is the standard correct syntax.

Take Test
Q.175 Medium C Programming
What will be printed by: int x = 5; printf("%d", ++x + x++);?
A 11
B 12
C 13
D 14
Correct Answer:  B. 12
Explanation:

++x increments x to 6 (pre-increment), then x++ returns 6 and increments x to 7. So: 6 + 6 = 12. Post-increment returns the old value.

Take Test
Advertisement
Q.176 Medium C Programming
Which of the following correctly uses the ternary operator?
A x = (a > b) : a : b;
B x = (a > b) ? a : b;
C x = a > b ? a : b
D x = (a > b) -> a : b;
Correct Answer:  B. x = (a > b) ? a : b;
Explanation:

The ternary operator syntax is: condition ? value_if_true : value_if_false. Option B is the only correctly formatted statement.

Take Test
Q.177 Medium C Programming
What is the purpose of the const keyword when used with a pointer?
A To make the pointer variable unchangeable
B To make the pointed data unchangeable
C Both A and B depending on placement
D To allocate memory in the constant segment
Correct Answer:  C. Both A and B depending on placement
Explanation:

const int *ptr makes the data constant (const int * ptr). int * const ptr makes the pointer constant. The position of const matters.

Take Test
Q.178 Medium C Programming
What is the return type of malloc() function?
A int*
B char*
C void*
D size_t
Correct Answer:  C. void*
Explanation:

malloc() returns a void pointer (void*), which can be cast to any data type pointer as needed by the programmer.

Take Test
Q.179 Medium C Programming
In the expression: int arr[10]; what is arr[5]?
A A pointer to the 5th element
B The value at memory address arr + 5
C Both A and B are equivalent
D An integer value between 0-10
Correct Answer:  C. Both A and B are equivalent
Explanation:

arr[5] accesses the element at index 5, which is at memory address (arr + 5). Array name arr acts as a pointer to the first element.

Take Test
Q.180 Hard C Programming
Consider: int *p, q; What is the type of q?
A Pointer to int
B Integer
C Pointer to pointer
D Character
Correct Answer:  B. Integer
Explanation:

Only p is declared as a pointer (int *p). The variable q is declared as a regular integer (int q). The * applies only to p in this declaration.

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