Write a program that asks the user to enter a list of integers.The integer can b
ID: 3649583 • Letter: W
Question
Write a program that asks the user to enter a list of integers.The integer can be either negative or positive.If the number is negative,the number is added to the negative sum;if the number is positive,the number is added to the positive sum.1)First,prompt the user to enter how many integers will be inputted(e.g,4)
2)Then use a single for loop to get the numbers from the user,and test if each number is negative or positive
3)Output the sum of the positive numbers and the sum of the negative numbers are inputted.
4)Output how many positive numbers are inputted and how many negative numbers are inputted.
For example,if the user input 3,-4,-6,1.You should output positive sum and negative sum.If the user input 0,remind the user that he has entered a number which is either positive or negative,and ask the user to re-enter a new integer
Note the invalid 0 should be counted toward the number of integers inputted by the user in the first place.For example if the user indicates 4 numbers he will input and if he enter 3,-4,4,0,he should have one or more chances to input a valid integer.
Explanation / Answer
#include using namespace std; int main() { char iChar; unsigned char uChar; signed char sChar; int iInt; short int sInt; unsigned int uInt; unsigned short int uShortInt; long int LInt; unsigned long int uLongInt; float iFloat; double iDouble; long double lDouble; 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.