এখানে আমরা C++-এর fdim() ফাংশন দেখব। fdim() ফাংশন দুটি আর্গুমেন্টের মধ্যে ধনাত্মক পার্থক্য রিটার্ন করে। যদি দুটি আর্গুমেন্ট a এবং b হয়, এবং a > b হয়, তবে a - b রিটার্ন করবে। অন্যথায় 0 রিটার্ন করবে।
উদাহরণ
#include <cmath>
#include <iostream>
using namespace std;
int main() {
cout << "fdim of (5.0, 2.0) is " << fdim(5.0, 2.0) << endl; // ধনাত্মক পার্থক্য
cout << "fdim of (2.0, 5.0) is " << fdim(2.0, 5.0) << endl; // 0 রিটার্ন করবে
cout << "fdim of (-5.0, -2.0) is " << fdim(-5.0, -2.0) << endl; // 0 রিটার্ন করবে
cout << "fdim of (-2.0, -5.0) is " << fdim(-2.0, -5.0) << endl; // ধনাত্মক পার্থক্য
return 0;
}
আউটপুট
fdim of (5.0, 2.0) is 3 fdim of (2.0, 5.0) is 0 fdim of (-5.0, -2.0) is 0 fdim of (-2.0, -5.0) is 3