answersLogoWhite

0

public class Add { public staticvoid main(String[] args) { int value=12; intcount=0; int sum=0; while(count<=4) { sum+=value%10; value=value/10; count++; } System.out.print("The sum of the individual integers is= "+ sum); } }

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

Write a program to subtract integer y from integer x?

x -=y;


How do you write a program in qbasic to input 64751315 to sum?

In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT &quot;Enter a number: &quot;; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT &quot;The sum of the digits is &quot;; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.


Write a program to find Armstrong number in visual basic 10?

An Armstrong number (or narcissistic number) for a given number of digits is a number that is equal to the sum of its own digits raised to the power of the number of digits. Here’s a simple Visual Basic 10 program that checks for Armstrong numbers: Module ArmstrongNumber Sub Main() Dim num As Integer Dim sum As Integer = 0 Console.Write(&quot;Enter a number: &quot;) num = Convert.ToInt32(Console.ReadLine()) Dim temp As Integer = num Dim digits As Integer = num.ToString().Length While temp &gt; 0 Dim digit As Integer = temp Mod 10 sum += Math.Pow(digit, digits) temp \= 10 End While If sum = num Then Console.WriteLine(num &amp; &quot; is an Armstrong number.&quot;) Else Console.WriteLine(num &amp; &quot; is not an Armstrong number.&quot;) End If End Sub End Module This program takes a number as input, calculates the sum of its digits raised to the power of the number of digits, and checks if the sum equals the original number.


How do you write a program in python to write the reverse of a number?

To write a program in Python that reverses a number, you can convert the number to a string, reverse the string, and then convert it back to an integer. Here's a simple example: def reverse_number(num): return int(str(num)[::-1]) number = 12345 reversed_number = reverse_number(number) print(reversed_number) # Output: 54321 This function takes an integer input, reverses its digits, and returns the reversed number.


Write a Shell program to find the sum of cube of individual digits of a number?

no thanks


How may ways are there to write 3 digit positive integer using 123456789 digits?

9*9*9 = 729 ways.


Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


How would i write a program that takes an integer as an input and reverses its digits as an output?

In java you can do it like this: import java.util.Scanner; public class Sample { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Input an integer: "); int i = input.nextInt(); System.out.print("reverse:"); while(i != 0) { System.out.print(i % 10); i = i / 10; } } }


How do you write a C Program to fill up an Integer Array?

Reference:cprogramming-bd.com/c_page1.aspx# array programming