← Back to C++ Course | Chapter 3: Operators | Lesson 1 of 9

C++ के Operators

Operators वे symbols हैं जो एक नई value produce करने के लिए एक या ज़्यादा operands पर काम करते हैं, और C++ इन्हें category में बांटता है -- arithmetic, relational, और logical -- वे जिस तरह का result produce करते हैं उसके आधार पर।
Syntax
cpp
result = operand1 operator operand2;

// operator: arithmetic (+ - * / %), relational (== != < >), logical (&& || !)

Operators क्या हैं?

एक operator एक special symbol है जो एक या ज़्यादा values पर, जिन्हें operands कहते हैं, एक operation perform करता है, एक नई value produce करते हुए -- उदाहरण के लिए, + symbol दो numeric operands को साथ add करता है।

उदाहरण: What are Operators?

cpp
#include <iostream>

int main() {
	int result = 5 + 3; // + is the operator, 5 and 3 are operands
	std::cout << result << std::endl;
	return 0;
}

C++ में Operators की Categories

C++ operators को इस आधार पर categories में बांटता है कि वे किस तरह का result produce करते हैं: arithmetic operators numbers compute करते हैं, relational operators values compare करते हैं और booleans produce करते हैं, और logical operators boolean values combine करते हैं।

उदाहरण: Categories of Operators in C++

cpp
#include <iostream>

int main() {
	int sum = 5 + 3;        // arithmetic
	bool isGreater = 5 > 3;  // relational
	bool bothTrue = true && isGreater; // logical
	std::cout << sum << " " << isGreater << " " << bothTrue << std::endl;
	return 0;
}

Operators और Operands

हर operator operands पर काम करता है -- + और * जैसे ज़्यादातर operators binary हैं और उन्हें दो operands चाहिए, जबकि ++ और unary - जैसे कुछ unary हैं और सिर्फ एक single operand पर काम करते हैं।

उदाहरण: Operators and Operands

cpp
#include <iostream>

int main() {
	int a = 5, b = 3;
	int sum = a + b;  // binary: two operands
	int negative = -a; // unary: one operand
	std::cout << sum << " " << negative << std::endl;
	return 0;
}

Expressions में Operators Combine करना

अलग categories के operators अक्सर एक single expression में combine होते हैं, जैसे एक if statement के अंदर इस्तेमाल होने वाली एक condition बनाने के लिए arithmetic और relational operators मिलाना।

उदाहरण: Combining Operators in Expressions

cpp
#include <iostream>

int main() {
	int price = 50, quantity = 3;
	if (price * quantity > 100) { // arithmetic + relational combined
		std::cout << "Order qualifies for discount" << std::endl;
	}
	return 0;
}

Operator Precedence का Preview

जब एक expression कई operators मिलाता है, C++ उन्हें एक fixed precedence order के हिसाब से evaluate करता है -- default से multiplication और division addition और subtraction से पहले चलते हैं, और parentheses हमेशा उस default order को override कर सकते हैं।

उदाहरण: Operator Precedence Preview

cpp
#include <iostream>

int main() {
	int result = 2 + 3 * 4;   // multiplication runs first: 14
	int overridden = (2 + 3) * 4; // parentheses override: 20
	std::cout << result << " " << overridden << std::endl;
	return 0;
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. conditions में = (assignment) को == (comparison) से confuse करना।
  2. यह उम्मीद करना कि 7 / 2 में integer division 3.5 देगा, जब दोनों operands ints हैं इसलिए result 3 है।
  3. यह मान लेना कि a + b * c left to right evaluate होता है, जब * की precedence + से ज़्यादा है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.