Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Do problem 4 in of the text. THINK about this program before beginning to code. Try to minimize the number of times each integer is
Do problem 4 in of the text. THINK about this program before beginning to code. Try to minimize the number of times each integer is tested as well as the number of if statements you use. My program only tests each integer twice, and has only 3 if statements in the code 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 usc "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 likc 15 debug:15 is positive (count = 1, total 15) debug :15 IS odd (count - 1, total = 15) debug : Total (count - 1, total = 15) debug: 2 is positive (count-2, total- 17) debug :2 is even (count - 1, total = 2) debug: 2 is positive and even (count, total- 2) debug Total (count2, total17) debug:-3 is negative (count -1, total--3) debug: -3 is odd (count - 2, total 12) debug:-3 is negative and odd (count -1, total3) debug : Total (count 3, total = 14) debug: -8 is negative (count2, total-11) debug :-8 is even (count = 2, total -6) debug : Total (count= 4, total = 6) 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 were1 negative odd numbers totaling -3 There were 4 total numbers totaling 6 4. 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 1. positive numbers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started