Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch6exercises;
- public class E61e {
- public static void main(String[] args) {
- int sum= 0;
- int digit=0;
- int number= 123456789;
- while ( number > 0 )
- {
- digit=number % 10;
- if ( digit %2 == 1 )
- {
- sum+=digit;
- }
- number/=10;
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement