Write a program which defines three variables of type double-02326

Online Quiz This subjective question is related to the book/course vu mth718 Topics in Numerical Methods. It can also be found in vu mth718 Mid Term Solved Past Paper No. 4.

Question 1: Write a program which defines three variables of type double which store three different values including decimal points, using setprecision manipulators to print all these values with different number of digits after the decimal number.
Answer:
#include
#include
main () {
double a = 12.12345;
double b = 13.123456;
double c = 14.1234567;
cout << setprecision (5) << a << endl;
cout << setprecision (2) << a << endl;
cout << setprecision (3) << a << endl;
}

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background