Question: Modify the code using setwidth, fixed and showpoint to print as shown in the output #include #include using namespace std; int main() { double x



Modify the code using setwidth, fixed and showpoint to print as shown in the output


#include

#include

using namespace std;


int main()

{

double x = 28.45678;

double y = 42.98;

double z = 123456.78915;

double c = 123.4, d = 12;


// show point will show the trailing zeros



// show point and fixed has been already set up


}

/*

X is 28.4568

Y is 42.98

With precision 1:

X is 3e+01

Y is 4e+01

With precision 2:

X is 28

Y is 43

With precision 3:

X is 28.5

Y is 43

With precision 4:

X is 28.46

Y is 42.98

With precision 5 and setw(8):

X is 28.457

Y is 42.98

Z is 1.2346e+05


C is 123.4

D is 12

With precision 5 :

C is 123.4

D is 12

With precision 5 and showpoint:

C is 123.40

D is 12.000

With precision 5 and noshowpoint:

C is 123.4

D is 12


With precision 2 fixed and setw(8):

X is 28.46

Y is 42.98

Z is 123456.79


With precision 5 and showpoint:

C is 123.40000

D is 12.00000


With precision 3 fixed and setw(4) and left justified:

X is 28.457

Y is 42.980

Z is 123456.789

With precision 3 fixed and left justified:

X is 28.457

Y is 42.980

Z is 123456.789

With precision 3 fixed and right justified:

X is 28.457

Y is 42.980

Z is 123456.789


*/




Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!