Kod:
#include <iostream>
using namespace std;
int main ()
{
int a,b;
string c;
cout <<"Enter the operation type (+ or -): "; cin >> c;
cout << "Enter the numbers: "; cin >> a >>b;
if (a==0 || b==0)
{
cout <<"Operation can not be done";
}
else if (c=="+" || c=="-")
{
if (c=="+")
{
double r;
r=(1/a)+(1/b);
cout <<"******\n";
cout <<"1/" << a << "+" <<"1/" << b << "=" << r << endl;
}
else
{
double r;
r=(1/a)-(1/b);
cout <<"******\n";
cout <<"1/" << a << "-" <<"1/" << b << "=" << r << endl;
}
}
else
{
cout <<"Invalid operation";
}
}
Program linkte bulunmaktadır.
İşlemi yaptığımda sonuç 0 geliyor, problemi çözemedim.
Son düzenleyen: Moderatör: