DEV Community

hema latha
hema latha

Posted on

while loop programes - sum and count

package day1;

public class Task {

public static void main(String[] args) {
    // TODO Auto-generated method stub

int no = 12345678;
int count = 0;
int sum = 0;
while(no>0)
{
    sum = sum + no%10;
    no=no/10;
    count = count+1;}
System.out.println(sum);
System.out.println(count);




}}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)