Operators:
An operator is the symbol that specify the operation or activity to be perform.
Example:
C language is very reach in operator the operators in cand be classified based on_
1. The number operant used by operator.
2. The type of operation being perform.
1. The number operant used by operator:
A mathematical expression consists of number and variable joined by operator such as +,-,*, the operator are classified in 3 category on operates.
1. Unary operator [a *, a/, a++]
2. Binary operator [a+b, 2/3, s*3]
3. Ternary operator [?;] (a>b ? a:b)
1.Unary operator: [a*, a/, a++]:
(a) Post: first use the value then update the value.
(b) Pre: first update the value then use the value.
(a) Post: 1. Post increment (a++)
2. Post decrement (a--)
Example:
If a=5
a++ then a=6
a-- then a=4
(b) Pre: 1. Pre increment (++a)
2. Pre decrement (--a)
Example:
If a=5
++a then a=6
--a then a=4
PROGRAM⤵️
(I). #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=6, b=7;
a++;
++b;
--a;
--b;
b--;
printf("%d%d",a,b); // a=6, b=6;
getch();
}
Output➡️. 66
(II) #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=6, b=7;
a=a+++b++;
b=b+++a++;
printf("%d%d",a,b);
getch();
}
Output➡️. 1418
2. Binary operator: [a+b, 2/3, s*3]:
Binary operators act upon a two operands to produce a new value (0 or 1).
Syntax for binary operator is:
operand1 operator operand2
3. Ternary operator: [?:] (a>b ? a:b):
If any operator is used on three operands or variable is known as Ternary Operator. It can be represented with ? : . It is also called as conditional operator.
It helps to think of the ternary operator as a shorthand way or writing an if-else statement. Programmers use the ternary operator for decision making in place of longer if and else conditional statements.
Syntax for ternary operator is:
(condition)?(statement 1):(statement 2);
Example:
(a>b)?printf('a is greater):printf("b is greater");
2. The type of operation being perform:
1. Arithmetic operator [+,-,*,%,/]
2. Assignment operator [*=,-=,+=,/=,%=]
3. Increment increase or decrease [++,--]
4. Relational operator [<=,>=,==]
5. Logical operator
6. Conditional operator [<,>,<=,>=,=][?,;]
7. Bitwise operator [~,<<,>>,&,!,^]
8. Special operator
1. Arithmetic operator:[+,-,*,%,/]:
The operator that are used to perform arithmetic operation such as +,-,*,/,% are called arithmetic operator can be classified in two types of this on the number of operants.
(I). Arithmetic binary operator
(II). Arithmetic Unary operator
2. Assignment operator:[*=,-=,+=,/=,%=]:
An operator which is used to copy the the data and result of an expression in a memory location is called assignment operator the assignment operator is donated by '=' sign
Syntax:
Variable=variable
Shorthand operator:
We can also used to shorthand and rotation for assignment operator such as-
Shorthand shorthand. Meaning
operator expression
+ = a+=10 a=a+10
- = a-=10 a=a- 10
* = a* =5 a=a* 5
/ = a/=? a=0/?
3. Increment or decrement operator:[++,--]:
These operator are very compact and powerful operators available in C language. These two operator are Unary operator use single operants are classified into two categories.
1. Unary operator [a *, a/, a++]
2. Binary operator [a+b, 2/3, s*3]
3. Ternary operator [?;] (a>b ? a:b)
Variable=variable
Shorthand operator:
हम assignment operator के लिए shorthand और rotation के लिए भी इस्तेमाल कर सकते हैं जैसे-
Shorthand shorthand. Meaning
operator expression
+ = a+=10 a=a+10
- = a-=10 a=a- 10
* = a* =5 a=a* 5
/ = a/=? a=0/?
3. Increment or decrement operator:[++,--]:
ये operator C language में उपलब्ध बहुत ही कॉम्पैक्ट और शक्तिशाली operator हैं। ये दो operator unary operator उपयोग एकल operators को दो श्रेणियों में वर्गीकृत किया गया है।
#include<stdio.h>
#include<stdio.h>
4. Relational operator:[<=,>=,==]:
Relational operator जिसे comparison operator भी कहा जाता है, का उपयोग दो operators की तुलना करने के लिए किया जाता है, जिनका उपयोग दो operators के बीच संबंध खोजने के लिए किया जाता है जो स्थिर होते हैं या variable expression होते हैं। इन दो operators के बीच 0 या 1 में संबंध।
5. Logical operator:
जैसा कि हमारे पास logic gates हैं जैसे कि AND,OR,NOT। जिसका output 1 या 0 हो उसके पास logical Operators भी हों। मूल्यांकन के बाद logical Operators से युक्त अभिव्यक्ति का परिणाम सही या गलत होता है। ऐसे व्यंजक Logical expression कहलाते हैं।
1. [&] AND (Binary operator)
2. [||] OR (Binary operator)
3. [!] NOT (Unary operator)
1. Logical AND:
Logical AND operation का परिणाम '&&' द्वारा निरूपित सत्य है यदि और केवल यदि दोनों Operators का मूल्यांकन सत्य के लिए किया जाता है यदि किसी एक का मूल्यांकन गलत है तो परिणाम गलत है।
If (a==b && b==c)
equilateral triangle
6. Conditional operator:
Conditional Operator को ternary operator को नाम index के रूप में भी कहा जाता है, एक operator जो operator और तीन operators को ternary operator कहा जाता है [?,|]
7. Bitwise operator:
Data को memory में binary digit, s के टर्म में store किया जाता है। यानी '0' या '1' कभी-कभी इन काटने में हेरफेर करना आवश्यक हो सकता है। bits में हेरफेर करने वालेे operators को bitwise operator कहा जाता है।
Operator. Description
~. Bitwise Identical [Negative]
<< Left shift
>> Right shift
& Bitwise AND
! Bitwise OR
^ Bitwise x-or
8. Special operator:
नीचे कुछ विशेष operator दिए गए हैं जो C programming language प्रदान करता है।
Operator Discription
&. This is used to get the
address Of the variable.
Example: &a will give address
of a.
*. This is used as pointer to a
variable.
Example: *a where, *is
pointer to the variable a.
Sizeof(). This gives the size of the
variable.
Example: size of (char) will
give as 1.
EXAMPLE PROGRAM FOR & AND * OPERATORS IN C:
#include<stdio.h>
Nice
ReplyDeletePerfect
ReplyDeleteOsm
ReplyDeleteSuper
ReplyDeleteVery perfect information sir, it will improve my knowledge. I really like it. I appreciate it heartily, dear sir
ReplyDeleteThank you
DeleteIf we talk of appearance of the page it is really awesome, moreover description of the facts is really good
ReplyDeleteI was seeking for some technical computer knowledge on likewise pages but nowhere could I find. And now I think my search ends here because I hope I'll get what I need. Thank you sir
ReplyDeleteThis is your nobility sir that you come to my blog and read it
DeleteThank you
Superrrrr
ReplyDeleteAmazing
ReplyDeletePerfect
ReplyDelete