C Programming
C language from basics to advanced placement prep
499 Questions 10 Topics Take Test
Advertisement
Showing 461–470 of 499 questions
Q.461 Medium Basics & Syntax
What will be the output of: int a = 5; int b = a < 10 ? 20 : 30; printf("%d", b);
A 5
B 10
C 20
D 30
Correct Answer:  C. 20
EXPLANATION

This is the ternary operator. Since 5 < 10 is true, b = 20. If false, b would be 30.

Take Test
Q.462 Medium Basics & Syntax
What is the purpose of the getchar() function in C?
A Get a string from input
B Get a single character from input
C Get a number from input
D Get a pointer from input
Correct Answer:  B. Get a single character from input
EXPLANATION

getchar() reads a single character from standard input and returns it. For strings, fgets() or scanf() is used.

Take Test
Q.463 Medium Basics & Syntax
In C99 and later standards, what is the purpose of 'inline' keyword?
A To declare variables inline
B A suggestion to the compiler to inline function calls
C To restrict variable scope
D To allocate memory inline
Correct Answer:  B. A suggestion to the compiler to inline function calls
EXPLANATION

'inline' is a hint to the compiler suggesting it should inline the function, though the compiler may ignore it.

Take Test
Q.464 Medium Basics & Syntax
What will be printed by: int arr[3] = {1, 2, 3}; printf("%d", *(arr + 1));
A 1
B 2
C 3
D Undefined
Correct Answer:  B. 2
EXPLANATION

arr + 1 points to the second element, so *(arr + 1) dereferences it to give 2.

Take Test
Q.465 Medium Basics & Syntax
Which of the following statements about NULL is correct?
A NULL is a keyword in C
B NULL is typically defined as (void *)0
C NULL and 0 are interchangeable for pointers
D Both B and C
Correct Answer:  D. Both B and C
EXPLANATION

NULL is a macro (not a keyword) typically defined as (void *)0, and can be used interchangeably with 0 for pointer assignments.

Take Test
Q.466 Medium Basics & Syntax
In C, what is the difference between #include and #include "stdio.h"?
A They are identical
B searches standard directories; "" searches current directory first
C "" is only for user-defined headers
D is only for system headers
Correct Answer:  B. searches standard directories; "" searches current directory first
EXPLANATION

Angle brackets search standard include directories, while quotes search the current directory first, then standard directories.

Take Test
Q.467 Medium Basics & Syntax
Which of the following is a correct way to initialize a character array with a string?
A char str[] = "Hello";
B char str[5] = "Hello";
C char *str = "Hello";
D All of the above
Correct Answer:  D. All of the above
EXPLANATION

All three are valid ways to work with strings in C, though they differ in memory allocation and mutability.

Take Test
Q.468 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.469 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.470 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
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