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)

Image of Quadratic

The best Excel alternative with Python built-in

Quadratic is the all-in-one, browser-based AI spreadsheet that goes beyond traditional formulas for powerful visualizations and fast analysis.

Try Quadratic free

👋 Kindness is contagious

Please consider leaving a ❤️ or a friendly comment if you found this post helpful!

Okay