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.
WRITE A PROGRAM TO CONVERT A 2-DIGIT bcd NUMBER INTO HEXADECIMAL
Write your own prime number program and find out.
#include<stdio.h> #include<conio.h> void main() { int no; clrscr(); printf("Enter a Number:"); scanf("%d",&no); if(no>0) printf("Your Number is Positive"); else printf("Your number is Negative"); getch(); }
How do you write 250% as a mixed number
To write a program that calculates the factorial of a number in PHP, you can use a recursive function or an iterative approach. Here’s a simple example using a loop: function factorial($n) { $result = 1; for ($i = 2; $i <= $n; $i++) { $result *= $i; } return $result; } echo factorial(5); // Outputs: 120 This code defines a function that multiplies numbers from 2 up to the given number $n to compute the factorial.
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"); } }
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
Start a new Visual C++ project then begin writing your C code.
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 "); } }
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".
WRITE A PROGRAM TO CONVERT A 2-DIGIT bcd NUMBER INTO HEXADECIMAL
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 c++ program to convert binary number to decimal number by using while statement
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 c++program by using if statement to read a number and check whether it is positive or negative