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 151–160 of 291
Topics in C Programming
Q.151 Easy Arrays & Strings
In C, when you declare an array like int arr[10], what does the array name 'arr' represent?
A A constant pointer to the first element of the array
B A variable pointer that can be reassigned
C The total size of the array in bytes
D A reference to the last element
Correct Answer:  A. A constant pointer to the first element of the array
EXPLANATION

Array names decay to pointers to their first element in most contexts. 'arr' is equivalent to &arr[0] and cannot be reassigned.

Test
Q.152 Easy Arrays & Strings
How many times will the following loop execute?
int arr[5]; for(int i=0; i
A 4 times
B 5 times
C Infinite loop
D 0 times
Correct Answer:  B. 5 times
EXPLANATION

Loop runs from i=0 to i=4, executing 5 times total. All array elements are initialized to 0.

Test
Q.153 Easy Arrays & Strings
How many bytes does a 2D array int arr[3][4] occupy in memory?
A 12 bytes
B 24 bytes
C 48 bytes
D 16 bytes
Correct Answer:  C. 48 bytes
EXPLANATION

int occupies 4 bytes. Array size is 3×4 = 12 elements. Total: 12 × 4 = 48 bytes.

Test
Q.154 Easy Arrays & Strings
Which function is used to find the length of a string in C?
A strlen()
B strsize()
C stringlen()
D getlength()
Correct Answer:  A. strlen()
EXPLANATION

strlen() is the standard library function defined in string.h that returns the length of a string excluding the null terminator.

Test
Q.155 Easy Arrays & Strings
What is the maximum size of a string that can be stored in char str[50]?
A 49 characters plus null terminator
B 50 characters plus null terminator
C 50 characters without null terminator
D Unlimited characters
Correct Answer:  A. 49 characters plus null terminator
EXPLANATION

A char array of size 50 can store maximum 49 characters because the last position is reserved for the null terminator '\0'.

Test
Q.156 Easy Arrays & Strings
What is the output?
int arr[] = {10, 20, 30, 40};
int *p = arr;
printf("%d", p[2]);
A 10
B 20
C 30
D 40
Correct Answer:  C. 30
EXPLANATION

p points to arr[0]. p[2] is equivalent to *(p+2), which points to arr[2] = 30.

Test
Q.157 Easy Arrays & Strings
Predict the output:
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
printf("%d", arr[1][2]);
A 5
B 6
C 8
D 9
Correct Answer:  B. 6
EXPLANATION

arr[1][2] refers to row 1, column 2, which contains 6.

Test
Q.158 Easy Arrays & Strings
What will be printed?
char *str = "Hello";
printf("%c", str[1]);
A H
B e
C l
D Compilation error
Correct Answer:  B. e
EXPLANATION

str[1] accesses the second character of the string, which is 'e'.

Test
Q.159 Easy Arrays & Strings
How many bytes are allocated by: int arr[10][20];?
A 200 bytes
B 400 bytes
C 800 bytes
D 2000 bytes
Correct Answer:  C. 800 bytes
EXPLANATION

10 rows × 20 columns × 4 bytes per int = 800 bytes (assuming 4-byte integer).

Test
Q.160 Easy Arrays & Strings
What is the output of strlen("Hello") in C?
A 5
B 6
C 4
D Runtime error
Correct Answer:  A. 5
EXPLANATION

strlen() returns the length of the string excluding the null terminator. "Hello" has 5 characters.

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