In this example, we have declared and initialized a 2-D array arr[2][3] of int datatype with 2 rows and 3 columns.
In this example, we have declared and initialized a 2-D array arr[2][3] of int datatype with 2 rows and 3 columns.
The bitwise AND operator is a single ampersand: &.It works on bits and not on bytes, chars, integers, etc. It does the logical AND of the bits in each position of the numbers in its binary form.
It is used to check for 2 or more logical expressions.
If both operands or logical expressions have values of true, the result has the value true. Otherwise, the result has the value false.
Basic syntax --> (logical expression/condition)? statement1:statement2.
If expression is true, statement 1 is executed else statement 2 is executed. It is an alternative to if else statement.
Unary operator are used to operate on a single operand.
Increment(++) and Decrement(--) operators are used to add 1 to the operand and subtract 1 from the operand respectively.
The two declarations of x refer to two different memory locations. The global x is altogether different from the x that is local to main().
Binary operators are used to operate on exactly two operands. +,-,*,/ and % are most commonly used Binary arithmetic operators.
Simple string program that will output the array position of letter from the given string.
Example:
Enter word : Today
Find the position of letter : y
y is at position 5
A cool trick with variables and pre-increment/decrement operators. This implements the initialization of variables with pre-increment/decrement operations.
It is default nature of a variable in c++.Every time it is declared it is initialized to the default value.