This is the code for finding an Armstrong number of 3 digits. But when i enter strings or any other special character it categorizes it as an armstrong number while it should be other way around.
#include <stdio.h>
#include <stdlib.h>
int main() {
int a, original, rev, rem;
printf("Enter the number : \n");
scanf("%d", & a);
original = a;
rev = 0;
while (a != 0) {
rem = a % 10;
rev = rev + (rem * rem * rem);
a /= 10;
}
if (rev == original) {
printf("Its an Armstrong number\n");
} else {
printf("Its not an Armstrong number \n");
}
}