#include <iostream.h>
#include <math.h>
#include <conio.h>
class squreroot {
    friend ostream& operator<<(ostream&, squreroot&);
    friend istream& operator>>(istream&, squreroot&);
public:
    squreroot();
    int disk() { return B*B-4*A*C; }
    float squreroot1() {return -B+sqrt(disk())/(2*A); }
    float squreroot2() {return -B-sqrt(disk())/(2*A); }
    void arithmetic_squreroot();
    void print_disk() { cout << "diskriminan = " << disk() << endl; }
    void print_squreroot() {
        cout << "x1 = " << squreroot1() << endl;
        cout << "x2 = " << squreroot2() << endl;
    }
private:
    int A, B, C;   // input
    float x1, x2;  // squreroot 1 and squreroot 2
};

ostream& operator<<(ostream& out, squreroot& output) {
    output.print_disk();
    if (output.disk() >= 0) output.print_squreroot();
    else out << "Squreroot imajiner";
    return out;
}

istream& operator>>(istream& in, squreroot& input) {
    cout << "Coefficient of rank2   : "; in >> input.A;
    cout << "Coefficient of rank1   : "; in >> input.B;
    cout << "Coefficient of rank0   : "; in >> input.C;
    return in;
}

squreroot::squreroot() {
    cout << "arithmetic squreroot quadratic equation\n";
}

void squreroot::arithmetic_squreroot() {
     if (A == 0) {
        cout << "not a quadratic equation.\n";
        cout << "Value squreroot = " << -C/B; }  else {
          if (disk() > 0) {
             x1 = squreroot1();
             x2 = squreroot2();
          }  else if (disk() == 0) {
                    x1 = squreroot1();
                    x2 = x1;
             }
     }
}

main() {
    squreroot kasus;
    cin >> kasus;
    kasus.arithmetic_squreroot();
    cout << kasus;
    getch();
    return 0;
}

Categories:

1 Response for the "C + + program Calculate the square root of the equation"

  1. What is a casino and how can I win real money?
    It's easy to 부산광역 출장샵 learn and use 정읍 출장마사지 to win money while playing 하남 출장안마 slots and other casino games online. However, 광명 출장마사지 casino gambling can be confusing because 의정부 출장안마 of

Post a Comment