Programming in C MCQ - Constants, Variables and Data Types

Correct AnswerOption D
Rate difficulty Rate difficulty:
Choose a difficulty.
Enumeration constants are integer constants, not ordinary modifiable variables. Their values can be compared and used in integer expressions. Enumeration types provide a convenient way to represent related named values such as states, modes, or categories.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption A
Rate difficulty Rate difficulty:
Choose a difficulty.

Let n = 7. It needs actually a 3 bit-field. But log (n + 1) + 1 will be log (8) + 1, i.e., 4, which is wrong.
If n = 8, 4 bits are needed. But, log (n - 1) + 1 will be log (7) + 1, which will have an integral part of 3.
log(n) + 1 will yield the correct result in both the cases.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption C
Rate difficulty Rate difficulty:
Choose a difficulty.
In C, constants are values that do not change during program execution. Constants may appear directly as integer, floating-point, character, or string literals. Symbolic constants can be introduced using #define, while const-qualified objects provide read-only access through the declared identifier. These mechanisms have different properties.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption A
Rate difficulty Rate difficulty:
Choose a difficulty.
Found this useful?
Follow:
Implicit type conversion occurs automatically when C evaluates expressions, performs assignments, or passes arguments under applicable conversion rules. Integer promotions and the usual arithmetic conversions determine how operands of different arithmetic types are converted to compatible types.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption A
Rate difficulty Rate difficulty:
Choose a difficulty.
For a nonnegative floating-point value, the expression (int)(x + 0.5) is a traditional way to round to the nearest integer by adding 0.5 and then truncating the fractional part. This approach is not generally correct for negative values. The standard math library provides round() and lround() for more general rounding.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Why Practice with Avatto?
High Quality MCQsExam-focused questions with accurate answers
Detailed ExplanationsStep-by-step explanations to enhance learning
Latest Exam PatternBased on updated syllabus and pattern
Performance AnalyticsTrack performance and improve weak areas
100% Free PracticePractice unlimited questions for free