(Counting positive and negative numbers and computing theaverage of numbers) Wri
ID: 3619042 • Letter: #
Question
(Counting positive and negative numbers and computing theaverage of numbers) Write a program that reads an unspecified number of integers,determines how many positivie and negative vales have been read,and computes the total average of the input values (not countingzeros). Your program ends with the input 0. Display theaverage as a floating-point number. Here is a samplerun: Enter an int value, the program exits if the input is 0: 1 2 -1 3 0 The number of positives is 3 The number of negatives is 1 The total is 5 The average is 1.25 (Counting positive and negative numbers and computing theaverage of numbers) Write a program that reads an unspecified number of integers,determines how many positivie and negative vales have been read,and computes the total average of the input values (not countingzeros). Your program ends with the input 0. Display theaverage as a floating-point number. Here is a samplerun: Enter an int value, the program exits if the input is 0: 1 2 -1 3 0 The number of positives is 3 The number of negatives is 1 The total is 5 The average is 1.25Explanation / Answer
//hope this will helpyou. #include #include using namespace std; int main() { int num_p,num_n,sum,count; int num; num_p= num_n = sum = count = 0; coutnum; if(num != 0) { if(num < 0 ) num_n ++; else num_p ++; sum += num; count ++; } }while(num != 0); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.