কম্পিউটার টিউটোরিয়াল

C++-এ লজিক্যাল অপারেটরদের রিটেন ভার্সন

C++ প্রোগ্রামিং ল্যাঙ্গুয়েজে, লজিক্যাল অপারেটরদের পরিবর্তে ব্যবহার করা যাওয়া কীওয়ার্ড আছে। কীওয়ার্ডগুলো প্রাথমিকভাবে C-এ ব্যবহৃত হতো যখন কিবোর্ডে &&, !, || এর মতো সিম্বল সাপোর্ট নাই। এখন, এখানে C++-এ লজিক্যাল অপারেটরদের রিটেন ভার্সন দেওয়া হলো।

অপারেটর এবং তাদের রিটেন ভার্সন —

অপারেটর সিম্বল রিটেন ভার্সন
And operator && and
Or operator || or
Not operator ! not
Not equal to operator != not_eq
Bitwise and operator & bitand
Bitwise or operator | bitor
Bitwise XOR operator ^ xor
And equal to operator &= and_eq
Or equal to operator |= or_eq
XOR equal to operator ^= xor_eq

আমাদের প্রোগ্রামের ইমপ্লিমেন্টেশন দেখানোর প্রোগ্রাম

উদাহরণ

#include <iostream>
using namespace std;

int main() {
    int x = 1, y = 0;
    cout << "Written logical operators are:\n";
    cout << x << " and " << y << " = " << (x and y) << endl;
    cout << x << " or " << y << " = " << (x or y) << endl;
    cout << x << " bitwise and " << y << " = " << (x bitand y) << endl;
    cout << x << " not equal to " << y << " = " << (x not_eq y) << endl;
    return 0;
}

আউটপুট

Written logical operators are:
1 and 0 = 0
1 or 0 = 1
1 bitwise and 0 = 0
1 not equal to 0 = 1

রিটেন অপারেটর ব্যবহার করার প্রস এবং কনস —

Pro — কোডের রিডেবিলিটি বাড়ায়।

Pro — এটি উপকারী যখন কিবোর্ডে |, &, !, ইত্যাদি ক্যারেক্টার সাপোর্ট না করে।

Cons — একটি স্টেটমেন্টে রিটেন কীওয়ার্ড ব্যবহার করলে, অপারেটর এবং অপারেন্ডের মধ্যে স্পেস দরকার নাহলে এরর হতে পারে।

  1. C++-এ লজিক্যাল অপারেটরসমূহ

  2. C++-এ রিলেশনাল অপারেটর

  3. C++-এ এরিথমেটিক অপারেটর

  4. C#-এ স্ট্রিংয়ের ওপর লজিক্যাল অপারেটরসমূহ