#!/bin/bash echo -n "Enter the nuber : " read read_val number=$read_val buf1=0 buf2=0 sum=0 while [ $number -gt 0 ] do buf1=`expr $number % 10` buf2=`expr $buf1 \* $buf1 \* $buf1` sum=`expr $sum + $buf2` number=`expr $number / 10` done if [ $sum -eq $read_val ] then echo "$read_val is armstrong number" else echo "$read_val not a armstrong number" fiOUTPUT:
(i)
Enter the nuber : 178
178 not a armstrong number
(ii)
Enter the nuber : 178
178 not a armstrong number
Armstrong Program in C++
ReplyDeleteArmstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself.
For example 153 is armstrong number, 132 is not prime number. Armstrong program in c++ is very simple and easy to write.