The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a program that reads a set of integers until a zero is entered. Excluding zero, the program should print a count of and a sum of:
Â
positive numbers
Â
negative numbers
Â
even numbers
Â
odd numbers
Â
positive even numbers
Â
negative odd numbers.
Â
all numbers
Â
Use debug statements to show cumulative sums as each new number is read and processed.
Â
Implement this program incrementally; i.e. first build the loop and test for only one set of conditions (e.g. even and odd). Get that program to work, and then add features to it a little at a time, testing as you go along. If you use "yank and put" in vi (copy and paste) and then modify the copy, you can save yourself alot of typing, since the different sections of this program are very similar to each other.
Â
Use #ifdef DEBUG conditional compilation around your debug statements to turn on and off debugging. Turn debugging off when you turn in your program. You can write this program with just a single function, main(). Put the code in a file called numbers.c. A sample output from my program looks like:
15 debug:15 is positive(count = 1, total = 15) debug:15 is odd(count = 1, total = 15) debug:Total(count = 1, total = 15) 2 debug:2 is positive(count = 2, total = 17) debug:2 is even(count = 1, total = 2) debug:2 is positive and even(count = 1, total = 2) debug:Total(count = 2, total = 17) -3 debug:-3 is negative(count = 1, total = -3) debug:-3 is odd(count = 2, total = 12) debug:-3 is negative and odd(count = 1, total = -3) debug:Total(count = 3, total = 14) -8 debug:-8 is negative(count = 2, total = -11) debug:-8 is even(count = 2, total = -6) debug:Total(count = 4, total = 6) 0 There were 2 positive numbers totaling 17 There were 2 negative numbers totaling -11 There were 2 even numbers totaling -6 There were 2 odd numbers totaling 12 There were 1 positive even numbers totaling 2 There were 1 negative odd numbers totaling -3 There were 4 total numbers totaling 6
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll