Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using C++ please, thnx in advance. 9. The following program contains errors. Correct them so that the program will run and output w = 20.(Hint:

using C++ please, thnx in advance.

9. The following program contains errors. Correct them so that the program will run and output w = 20.(Hint: please remove all commas, use parentheses as needed, and create compound statements for those bunched up statements following if and else. The modified code will have two compound statements, and the last cout statement must appear after the second compound statement)

#include

using namespace std

const int SECRET = 4;

int main ()

{

int x, y, w, z

cin >> z;

if z > 10

x = 2;

y = 5

w = x + y + SECRET,

else

x = 7;

y = 4

w = x + y + SECRET,

cout << "w*y*z = " << w*y*z << endl;

}

10. Write the missing statements in the following C++ program. This program prompts the user to input two numbers. If either of the numbers is 0, the program should output "both numbers must be nonzero! " and exit the program. If the first number is greater than the second number, it outputs the first number divided by the second number; if the first number is less than the second number, it outputs the second number divided by the first number; otherwise, it outputs the string "these numbers are equal".

#include

using namespace std;

int main()

{

double firstNum, secondNum;

cout << "Enter two nonzero numbers: ";

cin >> firstNum >> secondNum;

cout << endl;

//Missing statements

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions