Copyright

The following program contains errors. Correct them so that the program will run and output w =...

Question:

The following program contains errors. Correct them so that the program will run and output w = 21.

'#include using namespace std;

const int SECRET = 5

main ()

{ int x, y, w, z;

z = 9;

if z > 10

x = 12;

y = 5, w = x + y + SECRET;

else x = 12;

y = 4, w = x + y + SECRET;

cout << "w = " << w << endl;

Programming Constructs:

A program is a set of steps that the computer uses to control the order/flow in which instructions are executed . Each language has its own syntax defined by the compiler's parser, but there are general constructs that are similar across all programming languages.

Answer and Explanation: 1

Become a Study.com member to unlock this answer!

View this answer

The following C++ code contains the changes to the program to get the output of 21. These changes include fixing syntax errors, adding parentheses to...

See full answer below.


Learn more about this topic:

Loading...
5 Basic Elements Of Programming

from

Chapter 11 / Lesson 6
123K

Computer programming is built upon five basic elements, including the input, output, loops and conditionals, mathematical, and variables and data structures. Explore the concepts of computer programming, discover the five core elements of programming, and find out how each element contributes to a computer program.


Related to this Question

Explore our homework questions and answers library