C Programming
C language from basics to advanced placement prep
499 Questions 10 Topics Take Test
Advertisement
Showing 481–490 of 499 questions
Q.481 Medium Basics & Syntax
What is the range of values for 'signed char' in C (assuming 8-bit char)?
A 0 to 255
B -128 to 127
C -256 to 255
D 0 to 127
Correct Answer:  B. -128 to 127
EXPLANATION

A signed char is 1 byte (8 bits) and can represent values from -128 to 127 using two's complement representation.

Take Test
Q.482 Medium Basics & Syntax
In C, what is the purpose of the 'static' keyword when used with a global variable?
A To make it accessible only within the current file
B To allocate it on the stack
C To make it a constant
D To prevent memory deallocation
Correct Answer:  A. To make it accessible only within the current file
EXPLANATION

When 'static' is used with a global variable, it restricts its scope to the current file (internal linkage), making it not accessible from other files.

Take Test
Q.483 Medium Basics & Syntax
Which memory segment stores global variables in C?
A Stack
B Heap
C Data segment
D Code segment
Correct Answer:  C. Data segment
EXPLANATION

Global variables are stored in the data segment (also called BSS segment for uninitialized globals). Local variables use the stack.

Take Test
Q.484 Medium Basics & Syntax
Which of the following is NOT a valid data type modifier in C?
A unsigned long
B signed double
C long float
D unsigned char
Correct Answer:  C. long float
EXPLANATION

The 'long' modifier cannot be used with 'float'. You can only use 'double' or 'long double' for longer floating-point types.

Take Test
Q.485 Medium Basics & Syntax
What is the output of the following code?
#include
int main() {
int a = 5, b = 10;
a = b++;
printf("%d %d", a, b);
return 0;
}
A 5 10
B 10 11
C 11 11
D 10 10
Correct Answer:  B. 10 11
EXPLANATION

b++ returns the current value of b (10) before incrementing, so a = 10. Then b increments to 11.

Take Test
Advertisement
Q.486 Medium Basics & Syntax
Which of the following correctly initializes a 2D array?
A int arr[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
B int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
C Both A and B
D Neither A nor B
Correct Answer:  C. Both A and B
EXPLANATION

Both syntaxes are valid in C. The first uses row-major order without explicit braces, the second uses explicit nested braces.

Take Test
Q.487 Medium Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 10, y = 20;
int *p = &x, *q = &y;
*p = *q;
printf("%d %d", x, y);
return 0;
}
A 10 20
B 20 20
C 10 10
D 20 10
Correct Answer:  B. 20 20
EXPLANATION

*p = *q assigns the value of y (20) to x through the pointer p. So x becomes 20, y remains 20.

Take Test
Q.488 Medium Basics & Syntax
What will be printed by the following code?
#include
int main() {
float f = 0.1 + 0.2;
if(f == 0.3)
printf("Equal");
else
printf("Not Equal");
return 0;
}
A Equal
B Not Equal
C Compiler Error
D Runtime Error
Correct Answer:  B. Not Equal
EXPLANATION

Due to floating-point precision limitations, 0.1 + 0.2 does not exactly equal 0.3 in binary representation.

Take Test
Q.489 Medium Basics & Syntax
What is the size of the following structure in bytes (assuming 32-bit system)?
struct Point {
char c;
int x;
double d;
}
A 13
B 16
C 17
D 20
Correct Answer:  B. 16
EXPLANATION

Due to structure padding and alignment: char (1 byte) + padding (3 bytes) + int (4 bytes) + double (8 bytes) = 16 bytes.

Take Test
Q.490 Medium Basics & Syntax
What is the purpose of the void keyword in C?
A To declare empty variables
B To indicate absence of type or empty parameter list
C To declare null pointers
D To terminate a program
Correct Answer:  B. To indicate absence of type or empty parameter list
EXPLANATION

void indicates absence of a return type (void function) or an empty parameter list func(void). It can also represent a generic pointer (void *).

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