C++ Can someone solve

##Chapter four
4. The following program contains error. Correct them so that the program
will run and output w = 21

#include <iostream>
using namespace std;
Cout int w = 12
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 <L< end1;
}


1
2
3
4
5
#include <iostream>

int main(){
    std::cout << "w = 21";
}
helios hahah

but srsly though, this programming is yuck
So many errors.

Run it through a compiler and just fix the errors slowly but surely. When you first compile, almost every line will have an error, just work up to down, if you have any problems just ask.

If you are REALLY having problems, i have a link to the fixed code. Just say if you need it
Last edited on
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

Cout int w = 12

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 < L< end1;
}


Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

using namespace std;

//cout int w = 12
int main ()
{
Int x, y, w;
int z = 9;
int SECRET = 5;

if(z>10)
     x = 12; y = 5; w = x + y + SECRET;
else
     x = 12; y = 4; w = x + y + SECRET; 

cout << “w = “ << w << endl;


system("pause");
return 0;

}


What kind of a sick problem is this :)
closed account (48T7M4Gy)
What kind of a sick problem is this :)



system("pause");

I thinks it's a serious question in an assignment but I would love to see the academic reaction, or from the OP for that matter to the helios solution.
1
2
3
4
5
6
7
8
9
10
#include <iostream>

using namespace std;

//cout int w = 12
int main ()
{
Int x, y, w;
int z = 9;
int SECRET = 5;

I will defend that answer:
1. There are no constraints in the problem statement beyond "change source A into source B" and "source B must output string S", where string S is a constant.
2. There are only two non-blank lines in source A that don't give compiler errors. Everything will have to be modified anyway, so why not have a more sensible solution?

You can tell when someone is sloppy when they give you problems with trivial solutions.
closed account (48T7M4Gy)
@helios - no defence required
Last edited on
Topic archived. No new replies allowed.