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 141–150 of 291
Topics in C Programming
Q.141 Easy Pointers
What will be the size of a pointer variable on a 64-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D 16 bytes
Correct Answer:  C. 8 bytes
EXPLANATION

On a 64-bit system, a pointer is 8 bytes (64 bits) regardless of the data type it points to.

Test
Q.142 Easy Pointers
Which operator is used to get the address of a variable in C?
A *
B &
C ->
D .
Correct Answer:  B. &
EXPLANATION

The & operator (address-of operator) returns the memory address of a variable.

Test
Q.143 Easy Arrays & Strings
Consider the following code:

char str[] = "HELLO";
int len = 0;
while(str[len] != '\0') {
len++;
}
printf("%d", len);

What will be the output?
A 5
B 6
C 4
D Undefined behavior
Correct Answer:  A. 5
EXPLANATION

The string "HELLO" has 5 characters. The while loop counts characters until it encounters the null terminator '\0'. The output will be 5. The null terminator is not counted in the length.

Test
Q.144 Easy Arrays & Strings
What will be the size in bytes of int arr[5] on a 32-bit system?
A 5 bytes
B 10 bytes
C 20 bytes
D Depends on compiler
Correct Answer:  C. 20 bytes
EXPLANATION

On 32-bit systems, int is typically 4 bytes. 5 elements × 4 bytes = 20 bytes total.

Test
Q.145 Easy Arrays & Strings
What is the output of: int arr[] = {10, 20, 30}; printf("%d", *(arr+1));?
A 10
B 20
C 30
D Garbage value
Correct Answer:  B. 20
EXPLANATION

arr+1 points to second element (arr[1]). Dereferencing gives value 20.

Test
Q.146 Easy Arrays & Strings
What is the correct way to declare and initialize a string in C?
A char str = "Hello";
B char *str = "Hello"; OR char str[] = "Hello";
C String str = "Hello";
D char str[10] = {"Hello"};
Correct Answer:  B. char *str = "Hello"; OR char str[] = "Hello";
EXPLANATION

Option B shows two valid ways: pointer to string literal or character array. Option A is wrong (single char), C is wrong (no String type in C).

Test
Q.147 Easy Arrays & Strings
How many elements can be stored in a 2D array declared as int matrix[4][5]?
A 4 elements
B 5 elements
C 9 elements
D 20 elements
Correct Answer:  D. 20 elements
EXPLANATION

A 2D array with dimensions [4][5] contains 4 × 5 = 20 elements total.

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

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

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

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