Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is in C++ and I'm kind of stuck with how to create a function that gets the sum of the positive numbers and another
This is in C++ and I'm kind of stuck with how to create a function that gets the sum of the positive numbers and another function for the sum of the negative. This is the prompt:
And this is where I'm sitting with my code:
Please anything helps! Thank you so much!
1. The Sum, the Largest and the Smallest (required) Write a program that reads in 10 integer numbers. Your program should do the following things: 1) Determine the number positive or negative 2) Count the numbers of positive numbers, and negative 3) Calculate the sum of all the numbers 4) Calculate the average of all the numbers. 5) Find the largest and smallest numbers entered. - To simplify your program, you can write a separate program to find the largest and smallest number. The user enters the ten numbers just once each and the user can enter them in any order. Your program should not ask the user to enter the positive numbers and the negative numbers separately. Sample Output: Lab \#5 by John Smith - Sum, the Largest and the Smallest Please enter 10 numbers: Enter a number: 2 Enter a number: -5 Enter a number: 6 Enter a number: 9 Enter a number: -2 Enter a number: -10 Enter a number: 9 Enter a number: 15 Enter a number: 8 Enter a number: 3 There were a total of 6 positive numbers entered There were a total of 4 negative numbers entered The sum of all the negative numbers is: -25 (optional) The sum of all the positive numbers is: 44 (optional) The sum of all numbers is: 19 The average of all the numbers is: 1.9 The largest number is 15 The smallest number is -10 (Global Scope) \#include using namespace std; - int main() \{ int Pos =0,Neg=0, Zero =0,i,arr[10]; int Sum =0; float Aver; int input[10]; cout i=0; i0) Post+; else if (arr[i]==0) Zero++; else Neg++; \} coutStep 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