import java.io.*;
public class SumofDigitsofagivennumber
{
public static void main(String a[]) throws IOException
{
System.out.println("Welcome to the SumofDigitsofagivennumber project!");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String num0 = br.readLine();
System.out.println("Enter an Integer");
int num = Integer.parseInt(num0);
int sum=0;
while(num!=0){
sum+=num%10;
num=num/10;
}
System.out.println("The sum of digits of input is "+sum);
}
}
public class SumofDigitsofagivennumber
{
public static void main(String a[]) throws IOException
{
System.out.println("Welcome to the SumofDigitsofagivennumber project!");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String num0 = br.readLine();
System.out.println("Enter an Integer");
int num = Integer.parseInt(num0);
int sum=0;
while(num!=0){
sum+=num%10;
num=num/10;
}
System.out.println("The sum of digits of input is "+sum);
}
}
Comments
Post a Comment