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 1–10 of 27
Topics in C Programming
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
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
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
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
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
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
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.

Test
Which header file is required to use the malloc() function?
A
B
C
D
Correct Answer:  B.
EXPLANATION

malloc() and other dynamic memory allocation functions are declared in <stdlib.h>.

Test
What is the output of: char c = 65; printf("%c", c);
A 65
B A
C Invalid output
D Compilation error
Correct Answer:  B. A
EXPLANATION

%c format specifier prints the character representation of ASCII value 65, which is 'A'.

Test
Q.10 Easy Basics & Syntax
In C, what is the size of the 'char' data type?
A 1 bit
B 1 byte
C 2 bytes
D 4 bytes
Correct Answer:  B. 1 byte
EXPLANATION

By C standard, sizeof(char) is always 1 byte, regardless of platform.

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