Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following program, which has some errors in it, there might be some mi

ID: 2247251 • Letter: G

Question

Given the following program, which has some errors in it, there might be some missing statements as well. Correct the Program. include "iostream": int main Int x, y Int Const Pi = 3.14159 x = 2 x Pi x + 2 = y z = x + y cout > > x = > > x > > endl } Rewrite the corrected Program here: Given the declarations int i: long n: float x: float y: Write a valid C++ expression for each of the following algebraic expressions. Use calls to library function whenever they are useful. Also mention what include file you would need in each case. a. |i| (absolute value) b. |n| c. |x+y| d. |x|+|y|

Explanation / Answer

3)#include <iostream>

using namespace std;

int main() {

int x,y,z;

const int pi=3.14159;

x=2*pi;

y=x+2;

z=x+y;

cout<<"x="<<x<<endl;

return 0;

}

Output:

x=6

4)

#include <iostream>

#include<cmath>

using namespace std;

int main() {

int i;

long n;

float a,b,x,y;

i=abs(i);

n=abs(n);

a=x+y;

a=abs(a);

b=abs(x)+abs(y);

cout<<"i="<<i<<" n="<<n<<" a="<<a<<" b="<<b<<endl;

return 0;

}

output:

i=0 n=0 a=0 b=0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote