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 141–150 of 303
Topics in C Programming
Q.141 Easy Pointers
Identify the output:
char *str = "Hello";
printf("%c", *str);
A H
B Hello
C e
D Address
Correct Answer:  A. H
EXPLANATION

*str dereferences the pointer to get the first character of the string, which is 'H'.

Take Test
Q.142 Easy Pointers
Which of the following is NOT a valid pointer declaration?
A int *p;
B float *q;
C void *r;
D int &s;
Correct Answer:  D. int &s;
EXPLANATION

& is a reference operator used in C++, not in C. In C, pointers are declared using *.

Take Test
Q.143 Easy Pointers
What is a NULL pointer?
A Pointer pointing to address 0
B Uninitialized pointer
C Pointer with no name
D Invalid pointer
Correct Answer:  A. Pointer pointing to address 0
EXPLANATION

A NULL pointer is a pointer that points to memory address 0, indicating it doesn't point to any valid memory location.

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

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

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

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

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

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

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

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