pastebin - Unnamed - post number 1491801 Part of Slepp's Projects %u2014 Pastebin %u2014 TURL %u2014 Imagebin %u2014 Filebin Feedback -- English French German Japanese Hide Menu -- Switch Stylesheets Create Upload Newest Tools Donate Barnsk | Your Pastes | Settings | Logout Stuff to Do New Post Upload a Post Goto Newest Search Archives Tools / APIs Donate Paste Actions Download Raw Embed pBox URL Post to Twitter Bookmark/Share View Tree Remove Paste Information Site News Get a Pastebin What is This? Bugs? Statistics Paste Details C Source format, 24 minutes 16 seconds old, and 9 hits. Quick Search Recent Posts Something 28 secs Miscellany 2 mins 20 secs Miscellany 3 mins 23 secs amature 7 mins 22 secs Miscellany 9 mins 48 secs Actinnamits 10 mins 30 secs Action Script Miscellany 10 mins 39 secs HTML 4.0 Strict Untitled 14 mins 52 secs Miscellany 20 mins 33 secs Miscellany 24 mins 2 secs #gem rules 24 mins 6 secs Unnamed 24 mins 16 secs C Source Anonymous 24 mins 30 secs Unnamed 25 mins 9 secs Unnamed 25 mins 28 secs Unnamed Saturday, July 11th, 2009 at 8:36:26am MDT Font: Small - Normal - Large 1. /*#include 2. #include 3. #include 4. */ 5. #include 6. /* 7. int a[5]; 8. int i; 9. */ 10. char functname[20]; 11. int playcount = 0; 12. // int play; 13. 14. void comparator(); // This is the prototype definition of the function for ANSI C. They 15. void listnumbers(); // This is the prototype defintion of the function for ANSI C 16. void infinteloop(); 17. void printnumbers(); 18. void printstring(); 19. void swap(int *, int *); 20. char getplay(); 21. 22. main() { 23. while(1) { 24. char play; 25. /* play = getplay(); 26. while(play == 'y') { 27. int a; 28. printf("DID WE GET HERE? INFINTELOOP()???"); 29. scanf("%d" , &a); // INFINTE LOOP EXAMPLE 30. if(a==10) { 31. printf("end of infinte loop"); 32. 33. } 34. 35. } 36. */ 37. 38. int i; 39. printf("\n***********************"); 40. printf("\n*****INPUT CHOICE******"); 41. printf("\n***********************"); 42. printf("\n** 1. listnumbers() **"); 43. printf("\n** 2. comparator() **"); 44. printf("\n** 3. infinteloop() **"); 45. printf("\n** 4. printnumbers()**"); 46. printf("\n** 5. printstring() **"); 47. printf("\n***********************"); 48. printf("\n***********************"); 49. printf("\nInput 1-5: "); 50. scanf("%d", &i); 51. switch (i) { 52. case 1: 53. listnumbers(); 54. break; 55. case 2: 56. comparator(); 57. break; 58. case 3: 59. strcpy(functname, "infinteloop"); 60. play = getplay(); 61. while(play == 'y') { 62. infinteloop(); 63. } 64. break; 65. case 4: 66. printnumbers(); 67. break; 68. case 5: 69. printstring(); 70. break; 71. default: 72. printf("Invalid input"); 73. break; 74. } 75. // swap(1,2); 76. /* int r = rand() % 100; // RANDON NUMBER EXAMPLE - If you look at the last two digits of all of these numbers they would form our random set! To select just these numbers we can use an arithmetic calculation of the following form: That is, to get the number into the right range you simply take the remainder on dividing by 100, ie a value in the range 0 to 99. 77. printf("\nOk, time to guess %d... ", r); 78. scanf("%d" , &a); 79. while(a != r) { 80. printf("\nTry again..."); 81. if (a < r) { 82. printf("Too low.\n"); 83. } 84. else { 85. printf("Too high.\n"); 86. } 87. scanf("%d" , &a); 88. } 89. if(a == r) { 90. printf("\nCorrect! Look at the big brain on Bret!\n"); 91. } */ 92. } 93. return 0; 94. } 95. 96. void swap(int *a, int *b) { 97. int temp; 98. temp = *a; // temp is equal to the value of point a (whatever the first incoming param is) 99. *a = *b; // *a is equal to the value of pointer b (whatever the second incoming param is) 100. *b = temp; // now *b is equal to the value of temp (which was a) 101. // printf("%d" , a , b); 102. } 103. void printstring() { 104. char a[40]; 105. // strcpy(a, "hello"); 106. 107. //printf("OK lets have it, 40 characters max: "); 108. //scanf("%s", a); 109. printf("Thanks, here it is...\n\n"); 110. printf("%s", a); 111. printf("\n\n"); 112. 113. } 114. void infinteloop() { // under construction to fix overall control styles 115. int a; 116. printf("\nWe made it to infinteloop()\n"); 117. scanf("%d" , &a); // INFINTE LOOP EXAMPLE 118. while(a==10) { 119. printf("\nEnd of infinte loop...\n"); 120. break; 121. } 122. printf("\n We made it to return in infinteloop()..\n"); 123. } 124. 125. char getplay() { 126. int play; 127. printf("Play %s y/n ?" , functname); 128. play = -1; 129. while (play == -1) { 130. play=getchar(); 131. } 132. return play; 133. } 134. 135. void comparator(int play, int a, int b) { 136. printf("\nHello this is comparator()"); 137. printf("\nDo you want to play? Y=1 N=0: "); 138. scanf("%d" , &play); 139. while(play) { 140. printf("\nEnter first number: "); 141. scanf("%d" , &a); // %d represents the data type for numbers 142. printf("\nEnter second number: "); 143. scanf("%d" , &b); 144. 145. if(a>b) { 146. printf("\nFirst number greater than second"); 147. printf("\nDifference is: %d\n\n", a-b); 148. } 149. else if(a #include #include */ #include /* int a[5]; int i; */ char functname[20]; int playcount = 0; // int play; void comparator(); // This is the prototype definition of the function for ANSI C. They void listnumbers(); // This is the prototype defintion of the function for ANSI C void infinteloop(); void printnumbers(); void printstring(); void swap(int *, int *); char getplay(); main() { while(1) { char play; /* play = getplay(); while(play == 'y') { int a; printf("DID WE GET HERE? INFINTELOOP()???"); scanf("%d" , &a); // INFINTE LOOP EXAMPLE if(a==10) { printf("end of infinte loop"); } } */ int i; printf("\n***********************"); printf("\n*****INPUT CHOICE******"); printf("\n***********************"); printf("\n** 1. listnumbers() **"); printf("\n** 2. comparator() **"); printf("\n** 3. infinteloop() **"); printf("\n** 4. printnumbers()**"); printf("\n** 5. printstring() **"); printf("\n***********************"); printf("\n***********************"); printf("\nInput 1-5: "); scanf("%d", &i); switch (i) { case 1: listnumbers(); break; case 2: comparator(); break; case 3: strcpy(functname, "infinteloop"); play = getplay(); while(play == 'y') { infinteloop(); } break; case 4: printnumbers(); break; case 5: printstring(); break; default: printf("Invalid input"); break; } // swap(1,2); /* int r = rand() % 100; // RANDON NUMBER EXAMPLE - If you look at the last two digits of all of these numbers they would form our random set! To select just these numbers we can use an arithmetic calculation of the following form: That is, to get the number into the right range you simply take the remainder on dividing by 100, ie a value in the range 0 to 99. printf("\nOk, time to guess %d... ", r); scanf("%d" , &a); while(a != r) { printf("\nTry again..."); if (a < r) { printf("Too low.\n"); } else { printf("Too high.\n"); } scanf("%d" , &a); } if(a == r) { printf("\nCorrect! Look at the big brain on Bret!\n"); } */ } return 0; } void swap(int *a, int *b) { int temp; temp = *a; // temp is equal to the value of point a (whatever the first incoming param is) *a = *b; // *a is equal to the value of pointer b (whatever the second incoming param is) *b = temp; // now *b is equal to the value of temp (which was a) // printf("%d" , a , b); } void printstring() { char a[40]; // strcpy(a, "hello"); //printf("OK lets have it, 40 characters max: "); //scanf("%s", a); printf("Thanks, here it is...\n\n"); printf("%s", a); printf("\n\n"); } void infinteloop() { // under construction to fix overall control styles int a; printf("\nWe made it to infinteloop()\n"); scanf("%d" , &a); // INFINTE LOOP EXAMPLE while(a==10) { printf("\nEnd of infinte loop...\n"); break; } printf("\n We made it to return in infinteloop()..\n"); } char getplay() { int play; printf("Play %s y/n ?" , functname); play = -1; while (play == -1) { play=getchar(); } return play; } void comparator(int play, int a, int b) { printf("\nHello this is comparator()"); printf("\nDo you want to play? Y=1 N=0: "); scanf("%d" , &play); while(play) { printf("\nEnter first number: "); scanf("%d" , &a); // %d represents the data type for numbers printf("\nEnter second number: "); scanf("%d" , &b); if(a>b) { printf("\nFirst number greater than second"); printf("\nDifference is: %d\n\n", a-b); } else if(a