Computer Science, asked by somyasingh8710, 7 months ago


a) Write a program to find the sum of digits of an integer number, input by the user.
Name​

Answers

Answered by asthanwesha
4

Explanation:

class test

{

public static void main (int x)

{

int n,no,r,s;

n=x; no=n; s=0;

while(no>0)

{

r=no%10;

s=s+1;

no=no/10;

}

System.out.println("The sum of the digits of "+n+" is "+s);

}

}

INPUT: 123

OUTPUT: The sum of the digits of 123 is 6

I have done this Java program in the easiest way using parameterized input statement.....

hope it may help you,

Please mark me as the brainliest.......

Similar questions
Math, 3 months ago