Write a program to accept a number and count number of digits and check if it is odd number of digits or even number of digits (in java)
icse class 10th
i will mark you brainliest and follow you if you give me a correct answer
Answers
Answered by
0
Answer:
In this program, instead of using a while loop, we use a for loop without any body.
On each iteration, the value of num is divided by 10 and count is incremented by 1.
The for loop exits when num != 0 is false, i.e. num = 0.
Since, for loop doesn't have a body, you can change it to a single statement in Java as such:
for(; num != 0; num/=10, ++count);
Answered by
0
Answer:
I used a method called Boxing which is conversion of primitive type data(Integer in this case) to reference type data(String) it is in class 10 ICSE course
Explanation:
Attachments:
Similar questions