Here are some.... which some/all of you might know... but a quick revision or something new for you...
1. REFERNCE
An alternate name for an object in C++. It provides an alias name for previously defined variables(s).
SYNTAX: type &ref-name=var-name;
EXAMPLE: int total;
int &sum=total;
total=100;
cout<<sum<<" "<<total;
OUTPUT: 100 100
2. SETPRECISION MANIPULATOR using IOS flag
It is used to set number of decimal places using ios flag.
EXAMPLE: cout.setf(ios::fixed);
cout<<setprecision(5)<<12.345678;
OUTPUT: 12.34567 (No Rounding Off)
Additional ios flags:
left : displays left justified output
right : displays right justified output
showpoint : displays decimal and trailing zeros even if decimal places are not needed
uppercase : displays the "e" in E-notation as "E"
showpos : displays a leading plus(+) before the value
scientific : displays floating point numbers in scientific ("E") notation
fixed : displays floating point numbers in normal notation ,i.e, no trailing zeros and no scientific
notaions.
notaions.
3. SIZEOF Operator
Sizeof is a unary compile-time operator that returns length (in bytes) of the variable or parenthesized type-specifier that it precedes.
It can be used as:
sizeof var; (where var is a declared datatype)
sizeof (type) (where type is a C++ data type)
4. COMMA Operator
Comma operator is used to string together several expressions. The group of expressions separated by comma (,) is evaluated left-to-right in sequence and the result of rightmost expression becomes the value of the total comma-separated expression.
EXAMPLE: b=(a=3,a+1);
first assigns a the value 3 and then assigns b the value a+1 i.e., 4. The parenthesis are necessary because the comma operator has lower precedence than the assignment operator.
Sizeof is a unary compile-time operator that returns length (in bytes) of the variable or parenthesized type-specifier that it precedes.
It can be used as:
sizeof var; (where var is a declared datatype)
sizeof (type) (where type is a C++ data type)
4. COMMA Operator
Comma operator is used to string together several expressions. The group of expressions separated by comma (,) is evaluated left-to-right in sequence and the result of rightmost expression becomes the value of the total comma-separated expression.
EXAMPLE: b=(a=3,a+1);
first assigns a the value 3 and then assigns b the value a+1 i.e., 4. The parenthesis are necessary because the comma operator has lower precedence than the assignment operator.
If you like it or otherwise, then please comment below....!!!
Nice effort... :)
ReplyDeleteAll the best for future...!!!