Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 151–160 of 303
Topics in C Programming
Q.151 Easy Arrays & Strings
In the declaration char *str[5], what does the array represent?
A Array of 5 character pointers
B Pointer to array of 5 characters
C Single pointer to a string of 5 characters
D 5 pointers to individual characters
Correct Answer:  A. Array of 5 character pointers
EXPLANATION

The syntax char *str[5] declares an array of 5 pointers, each pointing to a character (or string). The brackets bind tighter than asterisk.

Take Test
Q.152 Easy Arrays & Strings
Which of the following correctly initializes a 2D array of integers?
A int arr[3][3] = {1,2,3,4,5,6,7,8,9};
B int arr[][] = {1,2,3,4,5,6};
C int arr[3][] = {{1,2},{3,4},{5,6}};
D int arr[3][3];
Correct Answer:  A. int arr[3][3] = {1,2,3,4,5,6,7,8,9};
EXPLANATION

Option A is valid - 2D arrays can be initialized with all elements in a single brace. Options B and C are invalid as at least one dimension must be specified.

Take Test
Q.153 Easy Arrays & Strings
What is the size of the string 'Hello' when stored in a character array with null terminator?
A 5 bytes
B 6 bytes
C 7 bytes
D Depends on compiler
Correct Answer:  B. 6 bytes
EXPLANATION

'Hello' has 5 characters plus 1 null terminator (\0), making total 6 bytes.

Take Test
Q.154 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.

Take Test
Q.155 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.

Take Test
Q.156 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.

Take Test
Q.157 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.

Take Test
Q.158 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'.

Take Test
Q.159 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.

Take Test
Q.160 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.

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