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

C++ STL-এ মডুলাস ফাংশন (modulus)


std::modulus হলো বাইনারি ফাংশন অবজেক্ট যা দুটি আর্গুমেন্টের মডুলাস (%) অপারেশন করে। <functional> হেডারে সংজ্ঞায়িত।

সিনট্যাক্স

template <class T> struct modulus : binary_function<T,T,T> {
    T operator()(const T& a, const T& b) const { return a % b; }
};

উদাহরণ

#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    int arr[] = {10, 20, 35, 45, 50, 61};
    int rem[6];
    transform(arr, arr+6, rem, bind2nd(modulus<int>(), 2));
    for (int i = 0; i < 6; i++)
        cout << arr[i] << " is " << (rem[i]==0?"even":"odd") << endl;
}

আউটপুট

10 is a even
20 is a even
35 is a odd
45 is a odd
50 is a even
61 is a odd
  1. C++ STL-এ tanh() ফাংশন

  2. C++ STL-এ atanh() ফাংশন

  3. C++ STL-এ cosh() ফাংশন

  4. C++ STL-এ sinh() ফাংশন