Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 h02 CS16 W19 6. (4 pts) Write an if-else statement that outputs the string Grade is B if the variable `score` is between 80
2 |
h02 |
CS16 W19 |
- 6. (4 pts) Write an if-else statement that outputs the string "Grade is B" if the variable `score` is between 80 and 90 (both limits included). Otherwise the if-else statement should output "Grade is not B" ?7. (4 pts) The program below intends to do the following: Repeatedly prompt the user to input an integer number. When the user no longer wants to continue entering numbers, output the sum of all the positive numbers entered by the user followed by the sum of all the negative numbers entered by the user. However, the given program has errors. Mark all logical and syntax errors in the program and provide corrections in the space provided to the right. Add missing statements if any.
#include
int main(){ int a , sumPositive, sumNegative; string promptContinue =" To continue enter Y/y "; string promptNum = " Enter a number: "; char response; while (response = 'y'||`Y') { cout << promptNum; cin >> a; if(a) sumPositive+=a; else sumNegative+=a; cout<< promptContinue; } cout<< "Sum of all the positive numbers is: "<< sumPositive<
Step 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