#inlcude <iostream> #include<iomanip> intmain(){ std::cout<<std::setprecision(2)<<floatnum; //start from the first num after fixed point std::cout<<fixed::std::setprecision(2)<<floatnum; //start from the first num before fixed point }
Common Keywords in C++ and C
Assignment Operators
Preincrement and
Postincrement
Preincrement => Increment a by 1, then use the new value of a in
the expression in which a resides.
Postincrement => Use the current value of a in the expression in
which a resides, then increment a by 1.
Ex:
1 2 3 4 5 6 7 8 9 10 11 12
#include<iostream> usingnamespace std; intmain(){ int a=1; cout<<a<<"\n"; cout<<a++<<"\n"; //do a=a+1 after cout int b=1; cout<<b<<"\n"; cout<<++b<<"\n"; //do b=b+1 before cout }
Title: Control Statement_1-程式設計筆記
Author: Shih Jiun Lin
Created at
: 2023-01-17 23:00:50
Updated at
: 2023-01-24 01:31:39
Link: https://shih-jiun-lin.github.io/2023/01/17/Chapter 3, Control Statement_ Part 1/