Home / Questions / Write the value of n after execution: char ch ='d'; int n = ch + 5;
Explanatory Question

Write the value of n after execution:

char ch ='d';
int n = ch + 5;

👁 53 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Answer

The value of n is 105.

Explanation

  1. char ch = 'd'; assigns the character 'd' to the variable ch. In ASCII, the character 'd' has a decimal value of 100.
  2. int n = ch + 5; adds 5 to the ASCII value of 'd', which is 100. So, 100 + 5 equals 105.

Therefore, the value of n will be 105.