computer_science:programming:cpp
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
computer_science:programming:cpp [2021/09/08 07:04] – created mana | computer_science:programming:cpp [2021/10/02 04:59] (current) – mana | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Defult Hello World: | + | ====== C++ ====== |
- | <code cpp> | + | |
- | #include < | + | |
- | using namespace std; | + | C++ is a programming language. |
- | int main(){ | + | Information about it will be added to this page. |
- | cout << | + | |
- | } | + | There will also be links to bits of codes for easy access: |
+ | * [[Computer Science: | ||
+ | |||
+ | |||
+ | ===== Formatting cout ===== | ||
+ | It is possible to format cout's output by including ''# | ||
+ | Then get access to these: | ||
+ | <code cpp> | ||
+ | cout << fixed << result << endl; // This will set the display to use fixed representation | ||
+ | cout << | ||
</ | </ | ||
+ | <code cpp> | ||
+ | cout << result << endl; // this would still show with the previous setprecision setting. | ||
+ | |||
+ | cout << setprecision(3) << result2; // the variable is not affect by set precision, so it would now show 3 decimals | ||
+ | |||
+ | cout << fixed << setprecision(2) << setw(15) << left << result << "End of line" << | ||
+ | Using setw we can force the display of a certain number of characters. In this case, if the variable is more than 15 characters, it will be truncated, if not then white spaces will be added. The next (optional) setting (in this case " | ||
+ | |||
+ |
computer_science/programming/cpp.1631052272.txt.gz · Last modified: 2021/09/08 07:04 by mana