Computer Science, asked by mofijul1, 1 year ago

write a program accept a number and find the sum of digits of the number


yakumoreyucurry: Is this program supposed to be written in Java or in QBASIC or in any other programming language?
mofijul1: in JAVA

Answers

Answered by booklover19
3
public class sum
{
public static void main(int n)
{
int r,sum=0;
while(n>0)
{
r=n℅10;
sum=sum+r;
n=n/10;
}
System.out.print(sum);
}
}
Similar questions