answersLogoWhite

0

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("Enter a number: ")
        num = Convert.ToInt32(Console.ReadLine())
        Dim temp As Integer = num
        Dim digits As Integer = num.ToString().Length

        While temp > 0
            Dim digit As Integer = temp Mod 10
            sum += Math.Pow(digit, digits)
            temp \= 10
        End While

        If sum = num Then
            Console.WriteLine(num & " is an Armstrong number.")
        Else
            Console.WriteLine(num & " is not an Armstrong number.")
        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.

User Avatar

AnswerBot

1mo ago

What else can I help you with?

Related Questions

Write a java program to check a number is Armstrong number?

import java.io.*; public class Jerry { public static void main(String as[]) throws IOException { int k=Integer.parseInt(as[0]); int n=k; int d=0,s=0; while(n>0) { d=n%10; s=s+(d*d*d); n=n/10; } if(k==s) System.out.println("Armstrong number"); else System.out.println("not Armstrong number"); } }


How do you write a program in visual foxpro?

Same with other Visual Basic program, programming in FoxPro will require you to have the right syntax.


Write a program to convert a 2 digit BCD number into hexadecimal number?

Write a program to convert a 2-digit BCD number into hexadecimal


How do you write a C program in visual studio 2012?

Start a new Visual C++ project then begin writing your C code.


How do you write a Java program to see whether a number is Armstrong or not... using Buffered Reader and stuff ....?

import java.io.*; class Armstrong { public static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a number"); int a=Integer.parseInt(in.readLine()); int n1=a,rev=0,d=0; while(a!=0) { d=a%10; rev=rev+d*d*d; a=a/10; } if(rev==n1) System.out.println("It is a armstrong number "); else System.out.println("It is not a armstrong number "); } }


What is Visual Basic Editor?

There have been many versions of Visual Basic. It is a program which allows you to write other computer programs. Each version of Visual Basic has come with an editor to allow you to write and edit code. This is called the "IDE", or "Integrated Development Environment".


2 Write a program to convert a 2-digit BCD number into hexadecimal?

WRITE A PROGRAM TO CONVERT A 2-DIGIT bcd NUMBER INTO HEXADECIMAL


Where do you find the applications such as visual basic or visual C plus plus in visual studio 2010 there appears to be no actual applications?

Once you have the Visual Studio program open, go to File->New Project and select the language you want to write your program in. If one or more languages do not appear, you probably didn't choose to have them installed when you installed Visual Studio.


Write a program which takes any number of days from the user the program should display the number of years number of months formed by these days as well as the remaining days?

Write a program which takes any number of days from the user. the program should display the number of years, number of months formed by these days as well as the remaining days.


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


Write a program By using if else statement to read a number and check whether it is positive or negative?

write a c++program by using if statement to read a number and check whether it is positive or negative