Posts

Showing posts from September, 2025

6.Ternary operator and 7. Bitwise Operators

 6.Ternary operator:               It is a conditional operator(?:) which minimalize the conditional statements.it is easily inserted between code. Syntax: Symbol: ‘?:’ (condition)? statement: else statement; (x > y)? x: y; C++ program: which is greater one? #include <iostream> using namespace std; int main() {     int a, b;     cout<<"Enter the two numbers" <<endl;     cin>> a >> b;         // Using ternary operator     int g_val = (a > b) ? a : b;     cout << "The biggest of two numbers is: " << g_val;     return 0; } Output: Enter the two numbers 45 56 The biggest of two numbers is: 56 7. Bitwise Operators:               If you want to...

5. Unary Operators

     These operators need a single value to process the expression. The unary Operators are listed below. 1.    Increment operator (++) and Decrement operator(--): This operator deals with pre-increment(++Operand), post-increment(operand++), pre decrement(--Operand) and post decrement(Operand--).      Program: #include <iostream> using namespace std; int main() {     int x,y,z;     cout<<"Enter the number:";     cin>>x;     //pre increment     y = ++x;     //post incremnt     z = x++;     cout << "Pre increment value: " << y <<endl ;     cout << "Post increment value: " << x <<endl;     return 0; } Output: Enter the number:6 Pre increment value: 7 Post increment value: 8      Note ...