fork download
  1. #include <stdio.h>
  2.  
  3. long long int pow1(long long int j,long long int i)
  4. {
  5. long long int loop,ans = 1;
  6. for(loop=1;loop<=(j-i-1);loop++)
  7. {
  8. ans = ans*10;
  9. }
  10. return ans;
  11. }
  12. int main()
  13. {
  14. while(1)
  15. {
  16. char arr[1001];
  17. long long int i,j=0,n=0,oddsum=0,evensum=0;
  18. char ch;
  19. for(i=0;i<1001;i++)
  20. {
  21. if(scanf("%c",&ch) == -1)
  22. break;
  23. else
  24. {
  25. // After every new line of input scanning loop will break
  26. if(ch == '\n')
  27. break;
  28. // Skip all the spaces as a input
  29. if(ch != ' ')
  30. {
  31.  
  32. arr[j] = ch;
  33. j++;
  34.  
  35. }
  36. }
  37. }
  38. // If this loop will check the user given 0 as a input or not
  39. for(i=0;i<j;i++)
  40. {
  41. long long int x;
  42. x = arr[i]-48;
  43. long long int power = pow1(j,i);
  44. n = n+(x*power);
  45. }
  46. // If the input is 0. Loop will break
  47. if(n==0)
  48. break;
  49. // This loop print the given number
  50. for(i=0;i<j;i++)
  51. {
  52. printf("%c",arr[i]);
  53. }
  54. // This loop will calculate the result
  55. for(i=0;i<j;i++)
  56. {
  57. n = arr[i]-48;
  58. if(i%2!= 0)
  59. {
  60. oddsum+=n;
  61. }
  62. else
  63. evensum+=n;
  64.  
  65. }
  66. unsigned long long int sum = oddsum-evensum;
  67.  
  68. if(sum==11 || sum==0 || sum==-11)
  69. printf(" is a multiple of 11.\n");
  70. else
  71. printf(" is not a multiple of 11.\n");
  72. }
  73.  
  74. return 0;
  75. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty