aiNayan

4(viii)

Nov 28th, 2020 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5. int n, o, p, q, r, s, t, u, v, w, x, digit = log10(n), a[digit], count = 0, z;
  6. printf("Enter the number: ");
  7. o = p = q = r = s = t = u = v = w = x = 0;
  8. scanf("%d", &n);
  9. while (n > 0) {
  10. z = n % 10;
  11. a[count] = z;
  12. n = n / 10;
  13. count++;
  14. }
  15. int i;
  16. for (i = 0; i < count; i++) {
  17. if (a[i] == 0)
  18. o++;
  19. else if (a[i] == 1)
  20. p++;
  21. else if (a[i] == 2)
  22. q++;
  23. else if (a[i] == 3)
  24. r++;
  25. else if (a[i] == 4)
  26. s++;
  27. else if (a[i] == 5)
  28. t++;
  29. else if (a[i] == 6)
  30. u++;
  31. else if (a[i] == 7)
  32. v++;
  33. else if (a[i] == 8)
  34. w++;
  35. else if (a[i] == 9)
  36. x++;
  37. }
  38. printf("No of 0=%d\nNo of 1=%d\nNo of 2=%d\nNo of 3=%d\nNo of 4=%d\nNo of 5=%d\nNo of 6=%d\nNo of 7=%d\nNo of 8=%d\nNo of 9=%d\n", o, p, q, r, s, t, u, v, w, x);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment