Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

499 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 441–450 of 499
Topics in C Programming
Which of the following demonstrates proper type casting in C?
A (int) 5.7
B int(5.7)
C int
D 5.7 as int
Correct Answer:  A. (int) 5.7
EXPLANATION

C uses C-style casting with parentheses: (type) expression. This converts 5.7 to integer 5.

Take Test
Consider: long long int x; What is the minimum guaranteed size of x according to C standard?
A 4 bytes
B 8 bytes
C 16 bytes
D Compiler defined
Correct Answer:  B. 8 bytes
EXPLANATION

According to C99 standard, long long int is guaranteed to be at least 8 bytes (64 bits).

Take Test
Which storage class variable is automatically initialized to 0 if not explicitly initialized?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

static variables are automatically initialized to 0 for numeric types and NULL for pointers if not explicitly initialized.

Take Test
In C, which storage class has the longest scope and lifetime?
A auto
B register
C static
D extern
Correct Answer:  D. extern
EXPLANATION

extern variables have global scope and exist throughout program execution. They can be accessed across multiple files.

Take Test
Which data type is most suitable for storing a decimal number with high precision?
A float
B double
C long double
D int
Correct Answer:  C. long double
EXPLANATION

long double provides maximum precision (typically 80-128 bits) for decimal numbers compared to float (32 bits) and double (64 bits).

Take Test
What happens when you declare a variable without initializing it?
A It's set to 0 automatically
B It contains garbage value (for auto variables)
C Compilation error occurs
D It's set to NULL
Correct Answer:  B. It contains garbage value (for auto variables)
EXPLANATION

Auto variables (local variables) contain unpredictable garbage values if not initialized. Static/global variables are initialized to 0.

Take Test
What is the output of this code?
float x = 5 / 2;
printf("%f", x);
A 2.500000
B 2.000000
C 5/2
D Compilation error
Correct Answer:  B. 2.000000
EXPLANATION

5/2 performs integer division (both operands are int), resulting in 2. This is then converted to float as 2.0.

Take Test
Which variable storage class has default initialization to 0?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

Static variables are automatically initialized to 0 by the compiler.

Take Test
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
Correct Answer:  A. 10
EXPLANATION

p is a pointer to x. *p dereferences the pointer, giving the value of x, which is 10.

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

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