C Programming — Basics & Syntax
C language from basics to advanced placement prep
35 Questions 10 Topics Take Test
Advertisement
Showing 1–10 of 35 questions in Basics & Syntax
Which of the following is NOT a valid variable name in C?
A _var123
B 123var
C var_123
D __var
Correct Answer:  B. 123var
EXPLANATION

Variable names cannot start with a digit. They must start with a letter or underscore. Option B violates this rule.

Take Test
What is the output of the following C program?
#include
int main() {
char str[] = "GATE";
printf("%d", sizeof(str));
return 0;
}
A 4
B 5
C 6
D Compilation Error
Correct Answer:  B. 5
EXPLANATION

sizeof(str) includes the null terminator. The string "GATE" has 4 characters plus 1 null terminator = 5 bytes.

Take Test
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
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
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
Advertisement
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
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
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
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.10 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
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