F
Fred Chateau
I found the following code in an online tutorial, and I'm having some
difficulty understanding it. Unfortunately, it did not list any expected
output examples for val.
What type is val? Is this statement comparing, adding, and subtracting ASCII
numbers?
if ('0' <= ch && ch <= '9') val = ch - '0';
else if ('A' <= ch && ch <= 'Z') val = 10 + ch - 'A';
else {val = 0; Console.WriteLine("invalid character {0}", ch);}
difficulty understanding it. Unfortunately, it did not list any expected
output examples for val.
What type is val? Is this statement comparing, adding, and subtracting ASCII
numbers?
if ('0' <= ch && ch <= '9') val = ch - '0';
else if ('A' <= ch && ch <= 'Z') val = 10 + ch - 'A';
else {val = 0; Console.WriteLine("invalid character {0}", ch);}