Home Subjects C Programming Basics & Syntax

C Programming
Basics & Syntax

C language from basics to advanced placement prep

27 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–27 of 27
Topics in C Programming
Q.21 Easy Basics & Syntax
What is the output of the following code?
#include
int main() {
int arr[] = {10, 20, 30};
printf("%d", *(arr + 1));
return 0;
}
A 10
B 20
C 30
D Error
Correct Answer:  B. 20
EXPLANATION

arr + 1 points to the second element. Dereferencing with * gives the value 20.

Test
Q.22 Easy Basics & Syntax
Which keyword is used to create a variable that cannot be modified after initialization?
A static
B const
C volatile
D extern
Correct Answer:  B. const
EXPLANATION

The 'const' keyword creates a constant variable that cannot be modified after initialization. The compiler enforces this at compile time.

Test
Q.23 Easy Basics & Syntax
Which escape sequence represents a tab character in C?
A \t
B \tab
C \n
D \s
Correct Answer:  A. \t
EXPLANATION

\t is the escape sequence for a tab character. \n is for newline, \s is invalid in C.

Test
Q.24 Easy Basics & Syntax
What is the purpose of the main() function in C?
A To declare variables
B To include header files
C Entry point of program execution
D To define functions
Correct Answer:  C. Entry point of program execution
EXPLANATION

The main() function is the entry point where program execution begins. Every C program must have a main() function.

Test
Q.25 Easy Basics & Syntax
What is the output of: printf("%d", 5 + 3 * 2)?
A 16
B 11
C 21
D 13
Correct Answer:  B. 11
EXPLANATION

Following operator precedence, multiplication (*) has higher precedence than addition (+). So 3*2=6, then 5+6=11.

Test
Q.26 Easy Basics & Syntax
What does the following code snippet output?
#include
int main() {
int x = 5;
printf("%d", x++);
return 0;
}
A 5
B 6
C undefined
D Compilation error
Correct Answer:  A. 5
EXPLANATION

x++ is post-increment. The value 5 is printed first, then x is incremented to 6.

Test
Q.27 Easy Basics & Syntax
Which of the following is the correct syntax to declare a variable in C?
A int x;
B int x
C int: x;
D declare int x;
Correct Answer:  A. int x;
EXPLANATION

In C, variable declaration requires a semicolon at the end. The syntax is 'data_type variable_name;'

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