C++ operators are symbols used to perform operations on variables and values like addition, comparison, logic, etc.
C++ ऑपरेटर symbols होते हैं जो variables और values पर operations (जैसे जोड़, तुलना, लॉजिक) करने में यूज़ होते हैं।
#include <iostream>
int main() {
int a = 5, b = 3;
std::cout << "Sum = " << a + b;
return 0;
}
Explanation: Adds two numbers.
व्याख्या: दो numbers को जोड़ता है।
Output: Sum = 8
#include <iostream>
int main() {
int a = 5, b = 3;
std::cout << "Difference = " << a - b;
return 0;
}
Explanation: Subtracts second from first.
व्याख्या: पहले में से दूसरे को घटाता है।
Output: Difference = 2
#include <iostream>
int main() {
int a = 5, b = 3;
std::cout << "Product = " << a * b;
return 0;
}
Explanation: Multiplies two numbers.
व्याख्या: दो numbers को multiply करता है।
Output: Product = 15
#include <iostream>
int main() {
int a = 10, b = 2;
std::cout << "Quotient = " << a / b;
return 0;
}
Explanation: Divides first by second.
व्याख्या: पहले number को दूसरे से divide करता है।
Output: Quotient = 5
#include <iostream>
int main() {
int a = 10, b = 3;
std::cout << "Remainder = " << a % b;
return 0;
}
Explanation: Gives remainder.
व्याख्या: शेषफल देता है।
Output: Remainder = 1
#include <iostream>
int main() {
int a = 4, b = 4;
std::cout << "Equal: " << (a == b);
return 0;
}
Explanation: Checks if both are equal.
व्याख्या: दोनों बराबर हैं या नहीं, चेक करता है।
Output: Equal: 1
#include <iostream>
int main() {
int a = 5, b = 3;
std::cout << "Not Equal: " << (a != b);
return 0;
}
Explanation: Checks if not equal.
व्याख्या: बराबर नहीं हैं या नहीं, चेक करता है।
Output: Not Equal: 1
#include <iostream>
int main() {
int a = 1, b = 0;
std::cout << "AND: " << (a && b);
return 0;
}
Explanation: True if both true.
व्याख्या: दोनों true हों तो true देता है।
Output: AND: 0
#include <iostream>
int main() {
int a = 1, b = 0;
std::cout << "OR: " << (a || b);
return 0;
}
Explanation: True if at least one true.
व्याख्या: कम से कम एक true हो तो true देता है।
Output: OR: 1