C Programming
C language from basics to advanced placement prep
1,000 Questions 10 Topics Take Test
Advertisement
Showing 931–940 of 1,000 questions
Q.931 Medium Basics & Syntax
What will be printed by: printf("%d", sizeof(float));
A 2
B 4
C 8
D Compiler dependent
Correct Answer:  B. 4
EXPLANATION

On most systems, sizeof(float) is 4 bytes. Though technically implementation-defined, 4 bytes is standard.

Take Test
Q.932 Medium Basics & Syntax
What is the correct syntax to define a macro with arguments in C?
A #define MAX(a, b) ((a) > (b) ? (a) : (b))
B #macro MAX(a, b) ((a) > (b) ? (a) : (b))
C #define MAX a, b ((a) > (b) ? (a) : (b))
D define MAX(a, b) ((a) > (b) ? (a) : (b))
Correct Answer:  A. #define MAX(a, b) ((a) > (b) ? (a) : (b))
EXPLANATION

The correct syntax uses #define followed by macro name and parameters, with the replacement text in parentheses.

Take Test
Q.933 Medium Basics & Syntax
What does the 'static' keyword do when used with a global variable?
A Makes it constant
B Limits its scope to the current file
C Allocates it on the stack
D Requires initialization
Correct Answer:  B. Limits its scope to the current file
EXPLANATION

Static global variables have internal linkage, restricting visibility to the translation unit where they are defined.

Take Test
Q.934 Easy Basics & Syntax
In C, which of the following correctly declares a pointer to an integer?
A int *ptr;
B *int ptr;
C int& ptr;
D pointer int *;
Correct Answer:  A. int *ptr;
EXPLANATION

The correct syntax is 'int *ptr;' where * indicates ptr is a pointer to int.

Take Test
Q.935 Hard Basics & Syntax
What is the result of: int x = 10; int y = x++ + x++;
A y = 20
B y = 21
C y = 22
D Undefined behavior
Correct Answer:  D. Undefined behavior
EXPLANATION

Multiple post-increments without sequence points lead to undefined behavior.

Take Test
Q.936 Easy Basics & Syntax
Which header file is required to use the malloc() function?
A
B
C
D
Correct Answer:  B.
EXPLANATION

malloc() and other dynamic memory allocation functions are declared in <stdlib.h>.

Take Test
Q.937 Easy Basics & Syntax
What is the output of: char c = 65; printf("%c", c);
A 65
B A
C Invalid output
D Compilation error
Correct Answer:  B. A
EXPLANATION

%c format specifier prints the character representation of ASCII value 65, which is 'A'.

Take Test
Q.938 Medium Basics & Syntax
What does the 'extern' keyword indicate in C?
A A variable exists in another source file
B A variable is local to a function
C A variable cannot be modified
D A variable is allocated on the stack
Correct Answer:  A. A variable exists in another source file
EXPLANATION

'extern' declares a variable or function that is defined in another translation unit (source file).

Take Test
Q.939 Easy Basics & Syntax
In C, what is the size of the 'char' data type?
A 1 bit
B 1 byte
C 2 bytes
D 4 bytes
Correct Answer:  B. 1 byte
EXPLANATION

By C standard, sizeof(char) is always 1 byte, regardless of platform.

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

This exhibits undefined behavior due to multiple modifications of the same variable 'x' without intervening sequence points.

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