Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 261–270 of 291
Topics in C Programming
Which keyword is used to declare a variable that cannot be modified?
A static
B const
C volatile
D extern
Correct Answer:  B. const
EXPLANATION

'const' keyword makes a variable constant and immutable after initialization.

Test
Which variable declaration is correct in C?
A int 2var;
B float var-name;
C char _var123;
D double var@name;
Correct Answer:  C. char _var123;
EXPLANATION

Variable names must start with a letter or underscore, followed by letters, digits, or underscores. Option C follows this rule correctly.

Test
What is the size of an 'int' variable in a 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D Compiler dependent
Correct Answer:  B. 4 bytes
EXPLANATION

In a 32-bit system, an int is typically 4 bytes (32 bits). However, the C standard only guarantees it's at least 2 bytes, so technically it's compiler-dependent. But in practice, 4 bytes is standard.

Test
Which of the following is NOT a fundamental data type in C?
A int
B float
C string
D char
Correct Answer:  C. string
EXPLANATION

C has 5 fundamental data types: int, float, double, char, and void. 'string' is not a fundamental type; it's created using char arrays.

Test
Q.265 Easy Basics & Syntax
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.

Test
Q.266 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.

Test
Q.267 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.

Test
Q.268 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.

Test
Q.269 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.

Test
Q.270 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.

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