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 431–440 of 499
Topics in C Programming
Which of the following correctly declares a constant integer variable?
A const int x = 10;
B int const x = 10;
C Both A and B are correct
D constant int x = 10;
Correct Answer:  C. Both A and B are correct
EXPLANATION

Both 'const int' and 'int const' are valid and equivalent ways to declare a constant integer in C.

Take Test
In the declaration 'int arr[10], *ptr;', which statement is correct?
A ptr is an array pointer, arr is an integer pointer
B ptr is a pointer to int, arr is an array of 10 integers
C Both arr and ptr are integer pointers
D arr is a pointer, ptr is an array
Correct Answer:  B. ptr is a pointer to int, arr is an array of 10 integers
EXPLANATION

The declaration uses comma separation. 'int arr[10]' declares an array of 10 integers, while '*ptr' declares a pointer to int.

Take Test
What is the size of int data type on a 32-bit system according to C standard?
A 2 bytes
B 4 bytes
C At least 2 bytes (implementation-dependent)
D 8 bytes
Correct Answer:  C. At least 2 bytes (implementation-dependent)
EXPLANATION

The C standard guarantees int is at least 2 bytes, but most 32-bit systems use 4 bytes. The exact size is implementation-dependent.

Take Test
A variable declared with 'register' storage class suggests to the compiler to store it in:
A Main memory
B CPU registers
C Hard disk
D Cache memory
Correct Answer:  B. CPU registers
EXPLANATION

register is a hint to compiler to store variable in CPU register for faster access. Compiler may ignore this if registers unavailable.

Take Test
What is the output of: printf("%d", sizeof(char) + sizeof(int) + sizeof(float)); on a typical 32-bit system?
A 4
B 9
C 12
D 13
Correct Answer:  B. 9
EXPLANATION

sizeof(char)=1, sizeof(int)=4, sizeof(float)=4 on 32-bit systems. Total: 1+4+4=9 bytes.

Take Test
Which of the following is a correct way to declare a constant variable in modern C?
A #define PI 3.14
B const float PI = 3.14;
C PI = 3.14 (const);
D constant float PI = 3.14;
Correct Answer:  B. const float PI = 3.14;
EXPLANATION

Option B is the correct C99/C11 syntax. #define is preprocessing, while const is a type qualifier that provides type safety.

Take Test
What happens when you attempt to store a double value in an int variable without explicit casting?
A Compilation error
B Runtime error
C The fractional part is silently truncated
D The value is rounded
Correct Answer:  C. The fractional part is silently truncated
EXPLANATION

Implicit conversion truncates the fractional part. Modern compilers may warn but allow this. Example: int x = 5.9; results in x = 5.

Take Test
In the declaration 'int *p, q;', what are the data types of p and q?
A Both are pointers to int
B p is pointer to int, q is int
C Both are int
D p is int, q is pointer to int
Correct Answer:  B. p is pointer to int, q is int
EXPLANATION

The * applies only to p. So p is int*, and q is int. To declare both as pointers: int *p, *q;

Take Test
Which keyword prevents a local variable from being optimized by compiler into a register?
A volatile
B static
C const
D restrict
Correct Answer:  A. volatile
EXPLANATION

volatile tells compiler that a variable's value may change unexpectedly and should not be optimized. It's often used for hardware registers.

Take Test
What is the difference between 'signed' and 'unsigned' char in terms of range?
A No difference
B signed: -128 to 127, unsigned: 0 to 255
C signed: 0 to 127, unsigned: -128 to 255
D signed: 0 to 256, unsigned: -128 to 128
Correct Answer:  B. signed: -128 to 127, unsigned: 0 to 255
EXPLANATION

Signed char uses 1 bit for sign, giving -128 to 127. Unsigned char uses all 8 bits for magnitude, giving 0 to 255.

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