Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Exercise 2 Using std_lib_facilities.h by Bjarne Stroustrup. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP // Chapter 7 Exercise 2 #include "std_lib_facilities.h" struct Token { char kind; double value; string name;…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Exercise 1 Using std_lib_facilities.h by Bjarne Stroustrup. Exercise 1. Allow underscores in the calculator’s variable names. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP // Chapter 7 Exercise 1 #include "std_lib_facilities.h"…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 11 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 11. Change the “quit keyword” from quit to exit. That will involve defining a string for quit just as we did for let in…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 10 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 10. Change the “declaration keyword” from let to #. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP // Chapter 7 Drill 10 /*…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 9 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 9. Allow the user to use pow(x,i) to mean “Multiply x with itself i times”; for example, pow(2.5,3) is 2.5*2.5*2.5. Require i to be…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 8 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 8. Catch attempts to take the square root of a negative number and print an appropriate error message. [code language=”cpp”] // Philipp Siedler //…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 7 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 7. Give the user a square root function sqrt(), for example, sqrt(2+6.7). Naturally, the value of sqrt(x) is the sqaure root of x; for…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 6 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 6. Add a predefined name k meaning 1000. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP // Chapter 7 Drill 6 /* calculator08buggy.cpp…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 5 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 5. Do the testing and fix any bugs that you missed when you commented. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP //…
Bjarne Stroustrup “Programming Principles and Practice Using C++” Chapter 7 Drill 1 Using std_lib_facilities.h by Bjarne Stroustrup. Drill 1. Starting from the file calculator08buggy.cpp, get the calculator to compile. [code language=”cpp”] // Philipp Siedler // Bjarne Stroustrup’s PP // Chapter 7 Drill…