Question:

In C language, what is the value of $ x - '0' $ where $ x $ is declared as char $ x = '5'; $?

Show Hint

When working with characters in C, subtract the ASCII value of '0' to get the integer equivalent of a character digit.
Updated On: May 3, 2025
  • 5
  • 4
  • 50
  • 53
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

In C, characters are stored as ASCII values. The ASCII value of the character '5' is 53. Subtracting the ASCII value of '0' (which is 48) from it gives \( 53 - 48 = 5 \).
Thus, the value of \( x - '0' \) is \( 5 \).
Was this answer helpful?
0
0

Top Questions on Programming in C

View More Questions