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)

Pieces AI Productivity Summit

​Join top AI leaders, devs, & enthusiasts for expert talks, live demos, and panels on how AI is reshaping developer productivity at the Pieces AI Productivity Summit.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️