+ 3
Now this eating up my brain. How does the output come a. b. c. d.
Char ch Int x=97; Do { Ch=(char)x; System.out.println(ch + " "); If (x%10==0) Break; ++X; While(x<=100); }
6 Réponses
+ 7
When you convert an int to a char, what the char hold is followed by ASCII code. You can search for it and you will see that 97 is 'a', 98 is 'b' and so on until 100.
+ 4
Man this is totally unexpected answer to the question
The real output is coming because of
•ascii values
•addition of values
Hope you get your answer👌
+ 4
I also have a question on this code. If you already have a do-while loop, why do you need an if-statment to stop it?
+ 2
habe a look at the ascii table. where ´a´=97, ´b´=97 and so on
+ 2
The if statement is used to terminate the loop when the integer value of the char is divisible by 10. As 'd' has an ASCII code of 100, the loop is terminated after printing 'd'.
+ 1
Its all about ASCII (American Standard Characters Information Interchange)