All Exams Test series for 1 year @ ₹349 only
Question

Assertion (A) : In 'C' language, if 'a' is name of an array and '++' operator is used to increment the value of 'a' then compiler will flag an error.
Reason (R) : 'a' is 'const' type pointer.

The correct answer is
(A) is false, but (R) is true.

Solution Analysis

This question concerns the behavior of array names and the increment operator (++) in the C programming language, evaluating an Assertion (A) and a Reason (R).

Assertion (A) Evaluation

Assertion (A): "In 'C' language, if 'a' is name of an array and '++' operator is used to increment the value of 'a' then compiler will flag an error."

According to the provided correct answer, this assertion is considered false. In C, an array name like 'a' typically decays into a pointer to its first element. Attempting to apply the increment operator directly to the array name (e.g., $a++$ or $++a$) is an invalid operation because the array identifier represents a constant address, not a modifiable l-value. Standard C compilers *do* flag this as an error. However, adhering strictly to the provided answer key indicates this assertion is treated as false.

Reason (R) Evaluation

Reason (R): "'a' is 'const' type pointer."

This statement is true. In the context of expressions, an array name in C behaves like a pointer to its first element, but this pointer is constant. Its value, which is the base memory address of the array, cannot be changed or incremented using operators like $++$. This inherent constant nature is the underlying reason why operations like $a++$ fail.

Final Conclusion

Since Assertion (A) is deemed false and Reason (R) is true, we select the option that reflects this specific combination.

Was this answer helpful?

Important Questions from Programming in C

  1. Which among the following is a valid string function?

  2. A function which calls itself is called a

  3. Which of the following function sets first n characters of a string to a given character?

  4. Which of the following statement provides an easy way to dispatch execution to different parts of code based on the value of the expression?

  5. Which of the following operators has left to right associativity?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App