Showing 91–100 of 100 questions
in Data Types & Variables
Which of the following is a derived data type in C?
A
int
B
Array
C
char
D
float
EXPLANATION
Derived data types are created from fundamental types. Arrays, pointers, structures, and unions are derived types.
What is the output of the following code?
int x = 10;
int *p = &x;
printf("%d", *p);
A
10
B
Address of x
C
Garbage value
D
Compilation error
EXPLANATION
p is a pointer to x. *p dereferences the pointer, giving the value of x, which is 10.
What is the difference between 'static' and 'extern' variables?
A
static has global scope, extern has local scope
B
static has file scope, extern has global scope
C
No difference
D
static is for functions, extern is for variables
Correct Answer:
B. static has file scope, extern has global scope
EXPLANATION
static restricts variable visibility to the current file; extern declares a variable defined elsewhere with global scope.
Which keyword is used to declare a variable that cannot be modified?
A
static
B
const
C
volatile
D
extern
EXPLANATION
'const' keyword makes a variable constant and immutable after initialization.
What is the range of unsigned int in a 32-bit system?
A
0 to 2^31 - 1
B
0 to 2^32 - 1
C
-2^31 to 2^31 - 1
D
0 to 2^16 - 1
Correct Answer:
B. 0 to 2^32 - 1
EXPLANATION
Unsigned int uses all 32 bits for magnitude, giving range 0 to 2^32 - 1 (0 to 4,294,967,295).
Which of the following occupies maximum memory in a 64-bit system?
A
long int
B
long double
C
double
D
unsigned long long
Correct Answer:
B. long double
EXPLANATION
In a 64-bit system, long double typically occupies 16 bytes (128 bits), which is the maximum among these options.
What will be the output of the following code?
int x = 5;
float y = x;
printf("%f", y);
A
5.000000
B
Compilation error
C
5
D
Garbage value
Correct Answer:
A. 5.000000
EXPLANATION
Implicit type conversion occurs from int to float. The value 5 is converted to 5.0 and printed as 5.000000 with %f format specifier.
Which variable declaration is correct in C?
A
int 2var;
B
float var-name;
C
char _var123;
D
double var@name;
Correct Answer:
C. char _var123;
EXPLANATION
Variable names must start with a letter or underscore, followed by letters, digits, or underscores. Option C follows this rule correctly.
What is the size of an 'int' variable in a 32-bit system?
A
2 bytes
B
4 bytes
C
8 bytes
D
Compiler dependent
Correct Answer:
B. 4 bytes
EXPLANATION
In a 32-bit system, an int is typically 4 bytes (32 bits). However, the C standard only guarantees it's at least 2 bytes, so technically it's compiler-dependent. But in practice, 4 bytes is standard.
Which of the following is NOT a fundamental data type in C?
A
int
B
float
C
string
D
char
Correct Answer:
C. string
EXPLANATION
C has 5 fundamental data types: int, float, double, char, and void. 'string' is not a fundamental type; it's created using char arrays.