Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

197 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 191–197 of 197
Topics in C Programming
Q.191 Hard Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 5;
int y = ++x * ++x;
printf("%d", y);
return 0;
}
A 42
B 49
C Undefined behavior
D Runtime Error
Correct Answer:  C. Undefined behavior
EXPLANATION

The expression ++x * ++x modifies x twice without an intervening sequence point, causing undefined behavior.

Test
Q.192 Hard Basics & Syntax
Which of the following correctly declares a function pointer?
A int *func;
B int (*func)();
C int func*();
D int *func();
Correct Answer:  B. int (*func)();
EXPLANATION

Function pointers require parentheses around the pointer name: int (*func)(). Option D declares a function returning int pointer, not a function pointer.

Test
Q.193 Hard Basics & Syntax
What is the main difference between #define and const in C?
A #define is preprocessed while const is handled by compiler
B const occupies memory while #define does not
C Both A and B
D There is no difference
Correct Answer:  C. Both A and B
EXPLANATION

#define is a preprocessor directive replaced before compilation, while const creates an actual variable. const occupies memory; #define does not.

Test
Q.194 Hard Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 5;
printf("%d", ++x + x++);
return 0;
}
A 12
B 13
C 11
D Undefined behavior
Correct Answer:  D. Undefined behavior
EXPLANATION

The expression ++x + x++ involves modifying x multiple times without an intervening sequence point, leading to undefined behavior in C.

Test
Q.195 Hard Basics & Syntax
Which storage class has a default value of 0 if not explicitly initialized?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

Static variables are initialized to 0 by default. auto and register variables have garbage values if not initialized. extern variables are declared elsewhere.

Test
Q.196 Hard Basics & Syntax
Consider the expression: int arr[5]; What does arr represent without the index?
A The first element of array
B Base address of the array
C Error - incomplete expression
D The entire array as a single value
Correct Answer:  B. Base address of the array
EXPLANATION

In C, the array name arr (without index) decays to a pointer to its first element, representing the base address.

Test
Q.197 Hard Basics & Syntax
What will be the output of: int x = 10; printf("%d %d", x, x++);
A 10 10
B 10 11
C 11 10
D Undefined behavior
Correct Answer:  D. Undefined behavior
EXPLANATION

Modifying and using a variable in the same expression without an intervening sequence point results in undefined behavior.

Test
IGET
IGET AI
Online · Exam prep assistant
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