fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7.  
  8. /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  9. int n,sum=0;
  10. scanf("%d",&n);
  11. int t=n;
  12. if(n<9){
  13. printf("Number should be greater than 9");
  14. exit(0);
  15. }
  16. while(n!=0){
  17. int num=n%10;
  18. sum+=num;
  19. n=n/10;
  20.  
  21. }
  22.  
  23. if((sum%9)==0){
  24. printf("%d is magic number for 9",t);
  25. }
  26. else
  27. printf("%d is not a magic number for 9",t);
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5376KB
stdin
32675
stdout
32675 is not a magic number for 9