Operators In C++
Dear Students, aaj ke is Lecture main hum Operators In C++ ke bare main padege. Yani ke operators kya hote hai Operators In C++ ka use kya hota hai. Or sath me he operators kitne types ke hote hai. Operators se related ye sare topic ham Operators In C++ ke lecture me cover karege.
Lectures Covering Topics
- Introduction To Operators In C++ In Hindi
- What Is Operators In C++ In Hindi
- Types Of Operators In C++ In Hindi
- Priority Of Operators In C++ In Hindi
Introduction To Operators In C++ In Hindi
To student jab hum kisi variable main koi value store karte hai. To hum us value ke sath kuch operations bhi performs kar sakte hai. Jaise ki do numeric value ko aapas me addition, multiplication, divination karana.
Ya fir words ki value ko count, frequency, matching, coordination aadi karana. Ye sab kaam kisi na kisi operators ke help se he ho sakta hai. Theek isi tarah aap different type ki value ke saath alag alag operation perform kar sakte hai.
Kisi bhi variable ke sath koi bhi operation perform karne ke liye hame different operators ka use karna padta hai. To chaliye padte hai operators in C++ ke bare main.
What Is Operators In C++ In Hindi
Jaisa ki mene aapko bataya ki operators ka use hum variables par operation perform karne ke liye karte hai. Sabhi data types par different types ke operation kiye jate hai. jaise ki multiply, addition, coordination etc.
Isi karan hum operators bhi different types ke use karte hai.Kisi bhi operation main jo bhi variable use kiye jate hai. Wo operand kahlate hai. Operators eak operand ke saath hi apply kiya jata hai.
Operator Binary or Unary two types ke hote hai. Binary operator 2 operands par apply kiye jate hai. Or unary operator sirf ek operand par apply kiya jata hai. Ab neeche likhe 1 line ke code se samjhte hai operators or operand kya hote hai.
Int X, Y, Z;
Z=X+Y;
Upar likhe code me x or y variable hai jo ki + operator ke sath use kiye gaye hai. Ye dono variable operand or + operator kahalate hai.
Types Of Operators In C++ In Hindi
To student ab hum padege ki C++ me kitne types ke operators hote hai. C++ me kai types ke operators hai joki neeche likhe hue hai.
- Unary Operator
- Arithmetic Operator
- Relational Operator
- Shift (Bitwise) Operator
- Logical Operator
- Ternary (Conditional) Operator
- Assignment Operator
Unary Operators In C++
Unary operator ka use karne ke liye hame sirf eak operand ki jaroorat hoti hai. Is operator ka use hum various operations ke liye karte hai.
- Value ko Increment/ Decrement karne ke liye
- Kisi Boolean value ko change karne ke liye
- Kisi expression ke unsuccessful karne ke liye
Unary Operators Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include<iostream> Using namespace std; int main() { int x=10; cout<<x++;//10 (11) cout<<x;12 cout<<x--;//12 (11) cout<<--x;//10 } |
Arithmetic Operators In C++
Arithmetic operators ka use hum mathematical operations ko perform karne ke liye karte hai. Ye five types ke hote hai addition, multiplication, subtraction, division, modules.
Arithmetic Operators Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include<iostream> Using namespace std; Void main() { int a=10; int b=5; cout<<(a+b);//15 cout<<(a-b);//5 cout<<(a*b);//50 cout<<(a/b);//2 cout<<(a%b);//0 } |
Shift (Bitwise) Operators In C++
Bitwise operators ka use bit by bit operations perform karne ke liye kiya jata hai. Ye operators variables ke value ko bit me convert karke un par operation perform karte hai.
Shift operators value ko bit bise manipulation karne main use kiya jata hai. C main three types ke shift operators hote hai.
- Left shift
- Right shift
- Right shift with zero fill >>> (or) unsigned right shift
Left Shift Operators Example
1 2 3 4 5 6 7 8 9 |
#include<iostream> Using namespace std; Void main() { cout<<(10<<2);//10*2^2=10*4=40 cout<<(10<<3);//10*2^3=10*8=80 cout<<(20<<2);//20*2^2=20*4=80 cout<<(15<<4);//15*2^4=15*16=240 } |
Right Shift Operators Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<iostream> Using namespace std; Void main() { cout<<(10>>2);//10/2^2=10/4=2 cout<<(20>>2);//20/2^2=20/4=5 cout<<(20>>3);//20/2^3=20/8=2 } |
Relational Operators In C++
Relational operators ka use 2 variables ke beech relation pata lagane ke liye kiya jata hai. Mostly inka use if statement main kiya jata hai. In operators ki helps aapko 2 variables ke beech relation pata chalta hai.
Jiase ki kya dono variable barabar hai ya fir eak choata ya bada hai. ye operators six types ke hote hai.
- Equal to (==)
- Not equal to (! =)
- Greater than (>)
- Less than (<)
- Greater than equal to (>=)
- Less than equal to(<=)
Relational Operators Example
1 2 3 4 5 6 |
X==Y X!=Y X>Y X<Y X<=Y X>=Y |
Logical Operators In C++
Logical operators ka use hum Boolean values par operations perform karne ke liye karte hai. ye operators 3 tarah ke hote hai AND(&&), OR(||), NOT(!). Is tarah ke operations me dono variable ki value True ya False hoti hai.
Logical Operators Example
1 2 3 4 5 6 7 8 9 10 11 |
#include<iostream> Using namespace std; Void main() { int a=10; int b=5; int c=20; cout<<(a>b||a<c);//true || true = true cout<<(a>b|a<c);//true | true = true //|| vs | } |
Ternary (Conditional) Operators In C++
Ternary operators ka use eak liner replacement ke roop me kiya jata hai. Yah operators 3 operand ko use karta hai. If-then-else statement ke sath use kiya jata hai. Ternary operators ko conditional operators bhi kha jata hai.
Ternary (Conditional) Operators Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<iostream> Using namespace std; Void main() { int a=2; int b=5; int min=(a<b)?a:b; cout<<min; } |
Assignment Operators In C++
Assignment operators ek most common operators hai. Is operators ka use value ko assing karne ke liye kiya jata hai. Kuch important assignment operators ke bare main neeche likha hua hai.
- Simple assignment (=)
- Plus assignment (+=)
- Minus assignment (-=)
- Multiply assignment ( * =)
- Divide assignment (/=)
Assignment Operators Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include<iostream> Using namespace std; Void main() { int a=10; int b=20; a+=4;//a=a+4 (a=10+4) b-=4;//b=b-4 (b=20-4) cout<<a; cout<<b; } |
Priority Of Operators In C++ In Hindi
Category | Types Operators | Associativity |
---|---|---|
Postfix | () [] -> . ++ – – | Left to right |
Unary | + – ! ~ ++ – – (type)* & sizeof | Right to left |
Multiplicative | * / % | Left to right |
Additive | + – | Left to right |
Shift | << >> | Left to right |
Relational | < <= > >= | Left to right |
Equality | == != | Left to right |
Bitwise AND | & | Left to right |
Bitwise XOR | ^ | Left to right |
Bitwise OR | | | Left to right |
Logical AND | && | Left to right |
Logical OR | || | Left to right |
Conditional | ?: | Right to leftt |
Assignment | = += -= *= /= %=>>= <<= &= ^= |= | Right to leftt |
Comma | , | Left to right |
Related Lecture
- What Is C++ Programming Language
- What Is Keyword In C++
- Variables In C++ In Hindi
- What Is Data Types In C++
Dear Students, main aasha karta hun ki aapko Operators In C++ Ka Lecture padh kar samjh me aa gaya hoga ki C++ main operators kya hai hote hai. Yadi aapako (Operators In C++) ke Lecture se related koi bhi problem hai to aap hume comment karke puch skte hai.
Leave a Reply