কম্পিউটার

একটি ভেরিয়েবলে যেকোন রৈখিক সমীকরণ সমাধান করার জন্য C++ প্রোগ্রাম


একটি চলকের যেকোন রৈখিক সমীকরণের aX + b =cX + d ফর্ম রয়েছে। এখানে X এর মান পাওয়া যাবে, যখন a, b, c, d এর মান দেওয়া হবে।

একটি চলকের মধ্যে একটি রৈখিক সমীকরণ সমাধান করার জন্য একটি প্রোগ্রাম নিম্নরূপ -

উদাহরণ

#include<iostream>
using namespace std;
int main() {
   float a, b, c, d, X;
   cout<<"The form of the linear equation in one variable is: aX + b = cX + d"<<endl;
   cout<<"Enter the values of a, b, c, d : "<<endl;
   cin>>a>>b>>c>>d;
   cout<<"The equation is "<<a<<"X + "<<b<<" = "<<c<<"X + "<<d<<endl;

   if(a==c && b==d)
   cout<<"There are infinite solutions possible for this equation"<<endl;
   else if(a==c)
   cout<<"This is a wrong equation"<<endl;
   else {
      X = (d-b)/(a-c);
      cout<<"The value of X = "<< X <<endl;
   }
}

আউটপুট

উপরের প্রোগ্রামের আউটপুট নিম্নরূপ

The form of the linear equation in one variable is: aX + b = cX + d
Enter the values of a, b, c, d :
The equation is 5X + 3 = 4X + 9
The value of X = 6

উপরের প্রোগ্রামে, প্রথমে a, b, c এবং d এর মান ব্যবহারকারী দ্বারা ইনপুট করা হয়। তারপর সমীকরণ প্রদর্শিত হয়। এটি নীচে দেওয়া হল -

cout<<"The form of the linear equation in one variable is: aX + b = cX + d"<<endl;

cout<<"Enter the values of a, b, c, d : "<<endl;
cin>>a>>b>>c>>d;

cout<<"The equation is "<<a<<"X + "<<b<<" = "<<c<<"X + "<<d<<endl;

a যদি c এর সমান হয় এবং b d এর সমান হয়, তাহলে সমীকরণটির জন্য অসীম সমাধান রয়েছে। a যদি c এর সমান হয়, তাহলে সমীকরণটি ভুল। অন্যথায়, X-এর মান গণনা করে প্রিন্ট করা হয়। এটি নীচে দেওয়া হল -

if(a==c && b==d)
cout<<"There are infinite solutions possible for this equation"<<endl;
else if(a==c)
cout<<"This is a wrong equation"<<endl;
else {
   X = (d-b)/(a-c);
   cout<<"The value of X = "<< X <<endl;
}
এর মান
  1. C++ এ আংশিক ভরা সুডোকু গ্রিড সমাধান করার জন্য প্রোগ্রাম

  2. একটি DAG-এর জন্য র‍্যান্ডম লিনিয়ার এক্সটেনশন তৈরি করতে C++ প্রোগ্রাম

  3. যেকোন ম্যাট্রিক্সের LU পচন সঞ্চালনের জন্য C++ প্রোগ্রাম

  4. একটি দ্বিঘাত সমীকরণের সমস্ত মূল খুঁজে পেতে C++ প্রোগ্রাম