✏️ Explanatory Question
char c = 'A'; int n = c + 1; char ch = (char)n;
Let's analyze the code step by step to determine the values of n and ch.
char c = 'A';
int n = c + 1;
char ch = (char)n;
Value of c:
c is assigned the character 'A'.'A' is 65.Calculation of n:
n is calculated as c + 1.c is 65, the calculation will be 65 + 1, which results in 66.Thus, n will be 66.
Value of ch:
ch is assigned (char)n.n is 66, so ch will be (char)66.66 is 'B'.Summary:
n is 66.ch is 'B'.