Question: a. Visit http://www.cplusplus.com/reference/clibrary/. Under Reference tab on the left side, There are 5 libraries on the list: C library, Containers, Input/output, Multi-threading and Other. Spend

a. Visit http://www.cplusplus.com/reference/clibrary/. Under Reference tab on the left side, There are 5 libraries on the list: C library, Containers, Input/output, Multi-threading and Other. Spend a few minutes browsing through the header files. To answer this question, look for three of the header files: iomanip, cmath and string. Then provide a brief description of each of them. b. Click on the iomanip header file. c. What is ? d. What is the ?

Question 2: Recall that if you want to use one predefined function from the C or C++ library, you have to include the header file at the top of your program and learn the signature of the function to know how to call it. PART1 Question 1 List three of parametric manipulators that you learned to format the output the signature of the setprecision function signature of the setw function x x1/ 2 Two functions that can be used to calculate the square root of a number are Function pow and function sqrt that are predefined Given that mathematical functions available in the library cmath with their signatures are: double pow (double base, double exponent); double result = pow(16,0.5); //result = 4 double sqrt (double x); double result = sqrt(16); // result = 4 The following program is an example that uses the predefined functions, pow and sqrt to calculate the square root of a number entered by the user. Save this program as sqrt.cpp to the folder lab5 in your working folder 1. //Calculate the square root of a number using sqrt and pow 2. #include 3. #include 4. 5. using namespace std; 6. 7. int main () 8. { 9. double x; 10.double result; 11. 12. cout << "Enter a (double) value: "; 13.cin >> x; 14. 15.result = pow(x, 0.5); 16. cout << "pow(" << x << ", 0.5) = " << result << endl; 17. 18.result = sqrt(x); 19. cout << "sqrt(" << x << ") = " << result << endl; 20. system("pause"); 21.return 0; 22. } a. Compile and run sqrt.cpp. What is the output if the user input is 169? b. Set up debug environment and start run the program with debug by following steps -SET UP TO SHOW LINE NUMBER OF THE CODE: click Tool tab, select Option at the bottom, click Text Editor on the Option window, select C/C++, then click on Line Number in the Display session, click OK - : click Debug tab, point to Window at top and select Breakpoint - : click on the lines that relate to variable x and result. For each line selected, press key Fn-F9 SET UP TO SHOW WATCHING BREAKPOINT WINDOW SET UP BREAK POINTS Start debug to run the program with input 1225: -Pressing F5 to start running the program with Debug modethe black window is display. to continue going to next line. For each line, you can watch the values of variable x and result in the window then write the answer to the table at the cell at ? as follows:student submitted image, transcription available below

Question 3: Convert the following if .. else if statement to switch statement: if ( x == 1 )

cout << This is the test 1 << endl; else if ( x == 2 || x==3)

cout << This is the test 2 ot test 3 << endl; else if ( x == 4)

cout << This is the test 3 or test 4 << endl; else cout << This is the other test << endl;

Line Number at Declaration Line Number When Initialized Variable Name Data Type Value in Memory Result Result Pressing Shift- F5 to stop debugging c. Test the program with the following input values of x without debug (press Fn-F5) Sqrt(x) Input Values (x) 49 289 729 1369 2209 3249 pow(x, 0.5)

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 Databases Questions!