write a program to check given number is ARMSTEONG or not
Answers
Answered by
0
include <stdio.h>
int main()
{
int number, originalNumber, remainder, result = 0;
printf("Enter a three digit integer: ");
scanf("%d", &number);
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber%10;
result += remainder*remainder*remainder; originalNumber /= 10;
}
if(result == number)
printf("%d is an Armstrong number.",number); else
printf("%d is not an Armstrong number.",number);
return 0;
}
int main()
{
int number, originalNumber, remainder, result = 0;
printf("Enter a three digit integer: ");
scanf("%d", &number);
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber%10;
result += remainder*remainder*remainder; originalNumber /= 10;
}
if(result == number)
printf("%d is an Armstrong number.",number); else
printf("%d is not an Armstrong number.",number);
return 0;
}
Similar questions
Computer Science,
7 months ago
Math,
1 year ago