forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Questions 17.35 & 17.36 missing from guide
Questions 17.35 & 17.36 missing from guide
- Loading branch information
1 parent
32996f7
commit c17dffb
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//@Squawk09 | ||
|
||
//17.35 | ||
//Write a version of the program from page 758, that printed the square root of 2 but this time print hexadecimal digints in uppercase | ||
#include <iostream> | ||
#include<iomanip> | ||
#include <math.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cout <<"default format: " << 100 * sqrt(2.0) << '\n' | ||
<< "scientific: " << scientific << 100 * sqrt(2.0) << '\n' | ||
<< "fixed decimal: " << fixed << 100 * sqrt(2.0) << '\n' | ||
<< "hexidecimal: " << uppercase << hexfloat << 100 * sqrt(2.0) << '\n' | ||
<< "use defaults: " << defaultfloat << 100 * sqrt(2.0) | ||
<< "\n\n"; | ||
} | ||
|
||
//17.36 | ||
//Modify the program from the previous exercise to print the various floating-point values so that they line up in a column. | ||
#include <iostream> | ||
#include<iomanip> | ||
#include <math.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cout <<left<<setw(15) << "default format:" <<setw(25)<< right<< 100 * sqrt(2.0) << '\n' | ||
<< left << setw(15) << "scientific:" << scientific << setw(25) << right << 100 * sqrt(2.0) << '\n' | ||
<< left << setw(15) << "fixed decimal:" << setw(25) << fixed << right << 100 * sqrt(2.0) << '\n' | ||
<< left << setw(15) << "hexidecimal:" << setw(25) << uppercase << hexfloat << right << 100 * sqrt(2.0) << '\n' | ||
<< left << setw(15) << "use defaults:" << setw(25) << defaultfloat << right << 100 * sqrt(2.0) | ||
<< "\n\n"; | ||
} |