VB .NET

VB .NET

Slip5

Q.1)  Write a Vb.net program to accept n numbers through InputBox and count the number of Armstrong and Perfect numbers among them and display their count by using messagebox.  [Marks 20] 

Solution


Public Class Slip5

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

Dim i, n, sum, r, temp As Integer
n = InputBox("enter the number")
sum = 0
temp = n
While n <> 0
r = n Mod 10
sum = sum + (r * r * r)
n = n \ 10
End While
If sum = temp Then
MsgBox("Number is armstrong", MsgBoxStyle.OkCancel) 
Else
MsgBox("Number is not armstrong", MsgBoxStyle.OkCancel)
 End If
 sum = 0
i = 1
n = InputBox("enter the number")
While i < n
If n Mod i = 0 Then
sum = sum + i
End If
i = i + 1
End While
If sum = n Then
MsgBox("number is perfect", MsgBoxStyle.OkCancel)
 Else
MsgBox("number is not perfect", MsgBoxStyle.OkCancel)
End If
End Sub

End Class
BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post