C Programming — Basics & Syntax
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 21–30 of 100 questions in Basics & Syntax
Q.21 Easy Basics & Syntax
What will be the output of: int x = 10; printf("%d", x++);
A 10
B 11
C Undefined
D Error
Correct Answer:  A. 10
EXPLANATION

x++ is post-increment. The current value (10) is printed first, then x is incremented to 11. So output is 10.

Take Test
Q.22 Easy Basics & Syntax
Which of the following is NOT a valid C data type?
A int
B string
C double
D char
Correct Answer:  B. string
EXPLANATION

C does not have a built-in 'string' data type. Strings are arrays of characters. int, double, and char are valid primitive data types.

Take Test
Q.23 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.24 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.25 Hard Basics & Syntax
What is the scope of a variable declared inside a block with 'static'?
A Global scope
B Function scope
C Block scope with static storage duration
D File scope
Correct Answer:  C. Block scope with static storage duration
EXPLANATION

A static variable declared in a block has block scope but static storage duration, persisting between function calls.

Take Test
Advertisement
Q.26 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.27 Easy Basics & Syntax
What will be the output of: printf("%d", 5 / 2);
A 2.5
B 2
C 3
D Error
Correct Answer:  B. 2
EXPLANATION

Integer division truncates the result. 5/2 = 2 (not 2.5) because both operands are integers.

Take Test
Q.28 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.29 Hard Basics & Syntax
What is the output of: int x = 5; int y = ++x + x++;
A y = 12
B y = 13
C Undefined behavior
D Compilation error
Correct Answer:  C. Undefined behavior
EXPLANATION

This involves undefined behavior due to modification of x multiple times without intervening sequence points.

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