Posts

Showing posts with the label Operators

Comma and Sizeof() operator

                                       Comma and Sizeof() operator      Comma Operator:- Comma operator( , ) is to separate declaration of two variables ,two data types.It is also helpful in scanning and printing,In built in functions. I can explain you with this below example:-   int a ,b ,c ,d; //<datatype><var.>,<var>;   float e; //<datatype><var.>,<var>;   printf("%d",a); scanf("%d",a);   Sizeof() :-  this operator is used get size of variable.I can explain you with this below example:-     int a,i; i=size of (int a) ; //out will be 2 because integer use 2 bytes in memory int =sizeof(datatype/variablr no.)   Operator Description Example sizeof() Returns the size of a...

Bitwise operator

                           Bitwise operator The c# bitwise operators I shall be covering here and are of particular interest to me in my followup post are: Bitwise AND( & ) Bitwise OR( | ) Bitwise NOT ( ! ) Bitwise XOR (^) Bitwise Shift operator Bitwise AND( & ):- And operators are predefined for the integral types and bool. For integral types, & computes the logical bitwise AND of its operands. For bool operands, & computes the logical AND of its operands; that is, the result is true if and only if both its operands are true. A B A & B True True True True False True False True True False False False   Bitwise OR( | ):- OR operators are predefined for the integral types and bool. For integral types, | computes the bitwise OR of its operands. For bool operands, | computes the logical OR of its op...

Conditional operator

                                                                                           Condition operator The Conditional operator (?:) is a ternary operator (it takes three operands)the condition operator work as follows:- The first operand is implicity converted to bool(true or false) It is evaluated and all side effects are completed before continuing. The conditional operator allows you to define a condition that returns a Boolean value. In addition to the condition, two expressions are provided. Only one of these expressions will be evaluated when the program is running, being selected according to the result of the condit...

Logical operators

                            Logical operators Operator Name && logical and || logical or ! logical not Not (!) T=F F=T Operator   And (&&) Or ( || )  T T T T F T F F T F F F Example:-   int a=10, b=20 a>5 && b<15                               (T)             (T)         (T) a>5||b<15                                    (F)          ...

Increment and decrement operator

                                Increment and decrement operator C# provides two operators that can be used to increase or decrease a variable's value by one. These are the increment operator (++) and decrement operator (--). These operators are known as unary operators because they are applied to a single value. The operators can be placed before the variable to be adjusted (prefix) or after it (postfix). postfix=i++;( In post i=i+i) prefix=++i;   (In pre i=i+i)                                                     Increment operator Example:- int a; i...

Assignment operator

                                                                                   Assignment operator A compound assignment operator is used to simplify the coding of some expressions. For example, using the operators described earlier we can increase a variable's value by ten using the following code: Using normal way:- a=a+2; a=a+b+2; a=a-2; a=a*4; a=a/5; a=a%2; The following code gives examples for addition (+=), subtraction (-=), multiplication (*=), division (/=) and modulus (%=): Using assignment operator:- a+=2; a+=b+2; a-=2; a*=4; a/=5; a%=2;    You may observe that by using assignment operator .It can save time,simplify the some ex...

Relational Operator

                                              Relational Operator These useful operators permit the developer to compare two values and make decisions based upon the result of the comparison. > Greater than >= Grater than equals to < Less than <= Less than equals to == Equals to != Not equals to Example:     int a=20;                  a>5 True a>25 False a>20 False a<=20 True a<25 True a<20 False a<=20 True a==20 True a==10 False a!=20 False a!=10 True

Arithmetic operators

                                                 Arithmetic operators There are five basic arithmetic operators available in C#. These are used for addition (+), subtraction (-), multiplication (*), division (/) and modulus (%). Of these, the first four are available to almost every programming language.     Operator Name + add - sub * mul / div % modulus (used for reminder)  Syntax:- int k=10,a,b,c,d,e;                                   a=k%2;     //output is ...

Operators

                                                                                                            Operators      Operators are special symbol which are used for arithmetic & logical calculations.C# provides a large set of operators, which are symbols that specify which operations to perform in an expression. Operations on integral types such as == , != , < , > , <= , >= , binary + , binary - , ^ , & , | , ~ , ++ , -- , and sizeof() are generally allowed on enumerations. In addition, many operators can be overloaded by t...