Expressions:
An expression is useful to perform a computation by using operators and operands.
In C#, we have three types of operators
· Unary operators: in this, we have only one operand.
· Binary operators: these can have two operands
· Ternary operators: it has three operands.
In c#, we have different kinds of operators
Ø Arithmetic operators:
in this type of operators, arithmetical operators are available. They are + , - , * , % , / , += , = , ++ , -- etc.by using this operators we can perform arithmetical computations like addition,substraction,multiplication,division,decrement,increment and more.
Ø Relational operators:
By using relational operators ,we can compare two expressions or values.in this we use operators like <,>,<= ,==,!=,>=
Ø Logical operatrors:
By using these operators ,we can combine two expressions into logical expressions.there three types of logical operators,they are
1. AND(&&)
2. OR (||)
3. NOT(!)
Ø Bitwise operators:
These operators evaluate the bits of a value directly
There are six logical operators
1. AND
2. OR
3. XOR
4. NOT
5. Shift left
6. Shift right
Example:
Class A
{
Static void main(string[] args)
{
int a ,b ,c ,d ,e ,f ;
a=1;
b= a + 5;
c= a + b;
c += 1;
d = a + b + c;
if (a > b)
{
e =10;
}
if (b <15 || c<5 )
{
f=3 ;
Console.writeline(f);
}
C++;
d--;
console.writeLine(c);
console.writeLine (d);
}
}
No comments:
Post a Comment