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

সি++-এ মেনু ড্রাইভেন সিম্পল ক্যালকুলেটর প্রোগ্রাম (Menu Driven C++ Program for a Simple Calculator)


এই টিউটোরিয়ালে, আমরা একটি মেনু ড্রাইভেন প্রোগ্রাম বানাব যা একটি সিম্পল ক্যালকুলেটরের জন্য।

এই প্রোগ্রাম ব্যবহারকারীকে নিচের গাণিতিক অপারেশনগুলোর মধ্যে বেছে নেওয়ার সুযোগ দেবে - যোগ, বিয়োগ, গুণ, ভাগ, HCF এবং LCM।

উদাহরণ

#include <bits/stdc++.h> using namespace std; // মেনু ডিসপ্লে void menu(){    cout << "Press 1 to calculate Sum of Numbers\n";    cout << "Press 2 to calculate Difference of Numbers\n";    cout << "Press 3 to calculate Product of numbers\n";    cout << "Press 4 to calculate Division of numbers\n";    cout << "Press 5 to calculate HCF of numbers\n";    cout << "Press 6 to calculate LCM of numbers\n";    cout << "Press 7 to exit\n"; } // ফলাফল ক্যালকুলেট ও আউটপুট void result(int choice, int a, int b){    switch (choice) {       case 1: {          cout << "Sum is " << (a + b) << "\n";          break;       }       case 2: {          cout << "Difference is " << (a - b) << "\n";          break;       }       case 3: {          cout << "Product is " << (a * b) << "\n";          break;       }       case 4: {          cout << "Division is " << (a / b) << "\n";          break;       }       case 5: {          cout << "GCD is " << __gcd(a, b) << "\n";          break;       }       case 6: {             cout << "LCM is "<< ((a * b) / __gcd(a, b))<< "\n";             break;       }       case 7: {          cout << "Thank you\n";          break;       }       default:       printf("Wrong Input\n");    } } int main(){    int a = 5, b = 7;    int choice, res;    menu();    cout << "Enter your choice:\n";    choice = 1;    cout << "Choice is " << choice << endl;    result(choice, a, b);    return 0; }

আউটপুট

Press 1 to calculate Sum of Numbers Press 2 to calculate Difference of Numbers Press 3 to calculate Product of numbers Press 4 to calculate Division of numbers Press 5 to calculate HCF of numbers Press 6 to calculate LCM of numbers Press 7 to exit Enter your choice: Choice is 1 Sum is 12

  1. C++-এ বাইনারি থেকে ডেসিমেল কনভার্সন প্রোগ্রাম

  2. C++-এ বর্গক্ষেত্রের এলাকা বের করার প্রোগ্রাম

  3. C++-এ পিরামিডের ভলিউম বের করার প্রোগ্রাম

  4. C++-এ কুইকসর্ট (QuickSort) প্রোগ্রাম