Write My Paper Button

WhatsApp Widget

Write a C++ program that inputs a list of integers of known size and uses acounter-controlled while loop to count of the number of positive integers, count the numberof negative integers and count

Part A:
Write a C++ program that inputs a list of integers of known size and uses a
counter-controlled while loop to count of the number of positive integers, count the number
of negative integers and count the number of zeros in the list. It also calculates the sum of
the positive integers and the sum of the negative integers.
After the while loop, it outputs the count of the positive integers, the count of the negative
integers and the count of the zeros in the list. It also outputs the sum of the positive integers
and the sum of the negative integers.
Also, it calculates and outputs the average of the list. The average should be formatted to
two digits after the decimal.
Test Case 1:
Enter the size of the list: 7 Enter an integer: 2
Enter an integer: 18 Enter an integer: 400 Enter an integer: -63 Enter an integer: 0
Enter an integer: -27
Enter an integer: 9
The count of the positives: 4
The count of the negatives: 2
The count of the zeros: 1
The sum of the positives: 429
The sum of the negatives: -90
The average of the list of integers: 48.43
Part B:
Add a for loop to the above program to test more than one set of integers.

Scroll to Top