C Programming
C language from basics to advanced placement prep
198 Questions 10 Topics Take Test
Advertisement
Showing 191–198 of 198 questions
Q.191 Hard Basics & Syntax
Consider a function declared as 'static int func()'. What is the scope of this function?
A Global scope across all files
B Limited to the current file only
C Only within the function where it's declared
D Limited to the current block
Correct Answer:  B. Limited to the current file only
EXPLANATION

When 'static' is applied to a function at file scope, it restricts the function's visibility to that translation unit (file) only.

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

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

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

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

Take Test
Advertisement
Q.196 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.

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

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

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