Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
w = 3.0/z + y*sqrt(-x)
PRECEDENCE OPERATORS highest NOT . *, /, DIV, MOD, AND . +, -, OR lowest <, <=, <, >, =, >=, >, INFully parenthisize
NOT x < 42 * 5 AND 6 = y
if ((x = getchar()) && c != ';') {
...
}
do {
x = getchar();
if (x == ';') break;
sum += x - '0';
} while(true);
sum = 0;
i = 1;
while (i < 4) {
sum = sum + i;
i = i + 1;
}
p.mag() = 3*4;.
Explain why it fails, and then explain why it cannot be fixed by
changing the defintion double& mag() { return sqrt(x*x + y*y); }
#include <iostream>
#include <cmath>
using namespace std;
class Point {
public:
double x, y;
public:
Point(double x, double y) { this->x = x; this->y = y; }
double& getX() { return x; }
double mag() { return sqrt(x*x + y*y); }
};
int main()
{
Point p(3,5);
p.getX() = 7*5;
p.mag() = 3*4;
return 0;
}