Another common programming technique is to use a for or while loop to cycle thro
ID: 3651970 • Letter: A
Question
Another common programming technique is to use a for or while loop to cycle through a set of numbers and select numbers meeting one or more criteria. For example, assume you want to find both the positive and negative sum of a set of numbers. Create the logic for implementing this program then construct the Program using a fixed-count loop in which five numbers are to be entered and determine whether the number is positive or negative then track the toal for positive and negative numbers.The following is a sample run of the Program:
Enter a number (positive or negative) : 10
Enter a number (positive or negative) :
Explanation / Answer
#include using namespace std; int main() { int posTotal=0; int negTotal=0; int n; for(int i=0;i0) posTotal+=n; else negTotal+=n; } coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.