fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5. int n, nod = 0, sod = 0, reverse = 0, aval = 0;
  6. printf("Enter a number : ");
  7. scanf("%d", &n);
  8.  
  9. for(int i = n; i > 0; i/=10)
  10. {
  11. nod++;
  12. sod += i%10;
  13. reverse = (reverse*10)+(i%10);
  14. }
  15.  
  16. printf("\nTotal No. digits : %d", nod);
  17. printf("\nSum of all digits : %d", sod);
  18. printf("\nReverse of %d is : %d", n, reverse);
  19.  
  20. if(n == reverse)
  21. printf("\n%d is a Palindrome Number", n);
  22. else
  23. printf("\n%d is not a Palindrome Number", n);
  24.  
  25. for(int i = n; i > 0; i /= 10)
  26. {
  27. aval += floor(pow(i%10, nod));
  28. }
  29. if (aval == n)
  30. printf("\n%d is an Armstrong Number", n);
  31. else
  32. printf("\n%d is not an Armstrong Number", n);
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 5448KB
stdin
121
stdout
Enter a number : 
Total No. digits : 3
Sum of all digits : 4
Reverse of 121 is : 121
121 is a Palindrome Number
121 is not an Armstrong Number