They can be used as shorthand notation too, , , , etc. & = |= ^= ~= Shift Operators Shift Operators are used to shift Bits of any variable. It is of three types, Left Shift Operator << Right Shift Operator >> Unsigned Right Shift Operator >>> Unary Operators These are the operators which work on only one operand. There are many unary operators, but increment and decrement operators are most used. ++ -- Other Unary Operators : address of dereference new and delete, bitwise not &, *, ~, logical not unary minus and unary plus !, - +. Ternary Operator The ternary if-else is an operator which has three operands. ? : int a = 10; a > 5 ? cout << "true" : cout << "false" Comma Operator This is used to separate variable names and to separate expressions. In case of expressions, the value of last expression is produced and used. Example : int a,b,c; // variables declaraation using comma operator a=b++, c++; // a = c++ will be done. (C) Explain use of followings in C++ programming, with an example program for each. Nested if It is always legal to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s). Syntax The syntax for a nested if statement is as follows: if( boolean_expression 1) { // Executes when the boolean expression 1 is true if(boolean_expression 2) { // Executes when the boolean expression 2 is true } } You can nest else if...else in the similar way as you have nested if statement. Example #include <iostream>
They can be used as shorthand notation too, & = , |= , ^= , ~= etc. Shift Operators Shift Operators are used to shift Bits of any variable. It is of three types, Left Shift Operator << Right Shift Operator >> Unsigned Right Shift Operator >>> Unary Operators These are the operators which work on only one operand. There are many unary operators, but increment ++ and decrement -- operators are most used. Other Unary Operators : address of &, dereference *, new and delete, bitwise not ~, logical not !, unary minus - and unary plus +. Ternary Operator The ternary if-else ? : is an operator which has three operands. int a = 10; a > 5 ? cout << "true" : cout << "false" Comma Operator This is used to separate variable names and to separate expressions. In case of expressions, the value of last expression is produced and used. Example : int a,b,c; // variables declaraation using comma operator a=b++, c++; // a = c++ will be done. (C) Explain use of followings in C++ programming, with an example program for each. Nested if It is always legal to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s). Syntax The syntax for a nested if statement is as follows: if( boolean_expression 1) { // Executes when the boolean expression 1 is true if(boolean_expression 2) { // Executes when the boolean expression 2 is true } } You can nest else if...else in the similar way as you have nested if statement. Example #include <iostream>
BCS-031-2017-18.output.docx