C Programming — Basics & Syntax
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 11–20 of 100 questions in Basics & Syntax
Q.11 Easy Basics & Syntax
What is the correct way to declare a two-dimensional array of integers with 3 rows and 4 columns?
A int arr[3][4];
B int arr[4][3];
C int **arr[3][4];
D int arr(3)(4);
Correct Answer:  A. int arr[3][4];
EXPLANATION

2D array syntax is int arr[rows][columns]. So int arr[3][4] creates 3 rows and 4 columns.

Take Test
Q.12 Medium Basics & Syntax
Which of the following about register variables is TRUE?
A They must be initialized
B They are faster to access than normal variables
C They cannot be pointers
D They are stored in RAM
Correct Answer:  B. They are faster to access than normal variables
EXPLANATION

register keyword suggests the compiler to store the variable in CPU register for faster access. Modern compilers often ignore this hint. You cannot take address of register variables.

Take Test
Q.13 Medium Basics & Syntax
What does the 'volatile' keyword in C indicate?
A Variable value can change unexpectedly
B Variable is constant
C Variable is local
D Variable must be initialized
Correct Answer:  A. Variable value can change unexpectedly
EXPLANATION

volatile tells the compiler that a variable's value can change unexpectedly (e.g., in hardware registers or interrupt handlers), so it should not optimize away repeated reads.

Take Test
Q.14 Medium Basics & Syntax
What is the output of: printf("%d %d", 10 % 3, 10 / 3);
A 3 3
B 1 3
C 3 1
D 10 10
Correct Answer:  B. 1 3
EXPLANATION

10 % 3 = 1 (remainder), 10 / 3 = 3 (integer division). Output is '1 3'.

Take Test
Q.15 Medium Basics & Syntax
Which of the following is correct about static variables in C?
A They are destroyed after function returns
B They retain their value between function calls
C They cannot be used in functions
D They are global by default
Correct Answer:  B. They retain their value between function calls
EXPLANATION

Static variables retain their value between function calls and are initialized only once. They persist for the lifetime of the program.

Take Test
Q.16 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.17 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.18 Easy Basics & Syntax
Which of the following correctly declares a pointer to an integer?
A int *ptr;
B int& ptr;
C ptr *int;
D int ptr*;
Correct Answer:  A. int *ptr;
EXPLANATION

The correct syntax for a pointer to int is 'int *ptr;' or 'int* ptr;'. & is a C++ reference, not used in C pointers.

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

\t is the escape sequence for horizontal tab. \n is newline, \h and \s are not valid escape sequences.

Take Test
Q.20 Easy Basics & Syntax
How many bytes does a 'long long' integer occupy in C (standard 32-bit system)?
A 2 bytes
B 4 bytes
C 8 bytes
D 16 bytes
Correct Answer:  C. 8 bytes
EXPLANATION

'long long' is guaranteed to be at least 64 bits (8 bytes) as per C99 standard.

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