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

C++-এ div() ফাংশন


C/C++ লাইব্রেরি ফাংশন div_t div(int numer, int denom) numer (নিউমেরেটর) কে denom (ডিনোমিনেটর) দিয়ে ভাগ করে। div() ফাংশন এর ডিক্লেরেশন নিচে দেওয়া হলো।

div_t div(int numer, int denom)

প্যারামিটারগুলো হলো নিউমেরেটর এবং ডিনোমিনেটর। এই ফাংশনটি একটি স্ট্রাকচারে ভ্যালু রিটার্ন করে যা -এ সংজ্ঞায়িত, যার দুটি মেম্বার আছে। div_t-এর জন্য: int quot; int rem;

উদাহরণ

#include <iostream> #include <cstdlib> using namespace std; int main () {    div_t output;    output = div(27, 4);    cout << "Quotient part of (27/ 4) = " << output.quot << endl;    cout << "Remainder part of (27/4) = " << output.rem << endl;    output = div(27, 3);    cout << "Quotient part of (27/ 3) = " << output.quot << endl;    cout << "Remainder part of (27/3) = " << output.rem << endl;    return(0); }

আউটপুট

Quotient part of (27/ 4) = 6 Remainder part of (27/4) = 3 Quotient part of (27/ 3) = 9 Remainder part of (27/3) = 0

  1. C++ STL-এ iswctype() ফাংশন

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

  3. C++-এ পিউর ফাংশন

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