Guest User

Untitled

a guest
Jan 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int counter()
  4. {
  5. int zeros, ones, twos, threes, fours, fives, sixs, sevens, eights, nines;
  6. int done = 0;
  7. int lastchar = 0;
  8. int c;
  9.  
  10. zeros = 0;
  11. ones = 0;
  12. twos = 0;
  13. threes = 0;
  14. fours = 0;
  15. fives = 0;
  16. sixs = 0;
  17. sevens = 0;
  18. eights = 0;
  19. nines = 0;
  20.  
  21. while(done == 0)
  22. {
  23. c = 112234;
  24.  
  25. if(c == '0')
  26. {
  27. ++zeros;
  28. }
  29. else if(c == '1')
  30. {
  31. ++ones;
  32. }
  33. else if(c == '2')
  34. {
  35. ++twos;
  36. }
  37. else if(c == '3')
  38. {
  39. ++threes;
  40. }
  41. else if(c == '4')
  42. {
  43. ++fours;
  44. }
  45. else if(c == '5')
  46. {
  47. ++fives;
  48. }
  49. else if(c == '6')
  50. {
  51. ++sixs;
  52. }
  53. else if(c == '7')
  54. {
  55. ++sevens;
  56. }
  57. else if(c == '8')
  58. {
  59. ++eights;
  60. }
  61. else if(c == '9')
  62. {
  63. ++nines;
  64. }
  65. else
  66. {
  67. printf("done");
  68. break;
  69. }
  70. }
  71. printf("zeros:%d \n ones:%d \n twos:%d \n threes:%d \n fours:%d \n fives:%d \n sixs:%d \n sevens:%d \n eights:%d \n nines:%d \n", zeros, ones, twos, threes, fours, fives, sixs, sevens, eights, nines);
  72. }
  73.  
  74. int main()
  75. {
  76. counter();
  77.  
  78. return 0;
  79. }
  80.  
  81. here is my code for the counter function so that it would count the digits in pi.c(junk and Yeats)
Add Comment
Please, Sign In to add comment