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

Write a short program that declares and initializes double variables one, two, t

ID: 3589557 • Letter: W

Question

Write a short program that declares and initializes double variables one, two, three, four, and five to the values 1.000, 1.414, 1.732, 2.000, and 2.236, respectively. Then write output statements to generate the following legend and table. Use the tab escape sequence t to line up the columns. If you are unfamiliar with the tab character, you should experiment with it while doing this exercise. A tab works like a mechanical stop on a typewriter. A tab causes output to begin in a next column, usually a multiple of eight spaces away. Many editors and most word processors will have adjustable tab stops. Our output does not. The output should be: N Square Root 1 1.000 2 1414 3 1.732 4 2.000 5 2.236

Explanation / Answer


#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
double one, two, three, four, five;
cout<<" N OUTPUT";
cout<<setprecision(3);
> two = sqrt(2);
three = sqrt(3);
four = sqrt(4);
five = sqrt(5);
cout<<fixed <<setprecision(4);
cout<<" 1" <<" " <<left <<setw(4) <<one;
cout<<" 2" <<" " <<two;
cout<<" 3" <<" " <<three;
cout<<" 4" <<" " <<four;
cout<<" 5" <<" " <<five;
return 0;
}


OUTPUT

N OUTPUT

1 1.000

2 1.414

3 1.732

4 2.000

5 2.236

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