C++ beginner s2-basic
Type
int iValue = 10;
bool bValue = true;
string sName = "Jason";
char cValue = 'g';
cout << "Size of int: " << sizeof(unsigned int) << endl;
cout << "Size of short int: " << sizeof(short int) << endl;Precision
#include <iomanip>
float fValue = 76.4;
cout << fixed << fValue << endl; // 76.400002
cout << scientific << fValue << endl; // 7.640000e+01
long double lValue = 123.456789876543210;
cout << setprecision(20) << fixed << lValue << endl; // 123.45678987654321190348if else
if (iValue == 1) {
cout << "Adding new record..." << endl;
} else if (iValue == 10) {
cout << "Deleting record..." << endl;
} else {
cout << "Invalid option." << endl;
}while
do while
for
continue / break
array
multi-dim array
switch
Last updated
Was this helpful?