Logo 
Search:

C Programming Article

Submit Article
Comments on PROGRAM USING WHILE LOOP TO DO SUM OF DIGITS OF THE NUMBER. NO IS - 12345 ANS IS 15
Category: C Programming (Homework Help)    Author: Dirck Jansen

WRITE A PROGRAM USNG WHILE LOOP TO DO SUM OF THE DIGITS OF THE NUMBER.
NO IS - 12345
ANS IS 15


Pran Pradeep
Pran Pradeep from IndiaDec 13
if we give input as 3456 its showing 21 :( :(


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim n As Integer
Dim j As Integer
Dim sum As Integer
n = TextBox1.Text

Do While n > 0

j = n Mod 10
sum += j
n /= 10

Loop
MsgBox(sum)
End Sub
End Class


Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].