-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA7Q2.cpp
More file actions
74 lines (62 loc) · 973 Bytes
/
A7Q2.cpp
File metadata and controls
74 lines (62 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <iomanip>
using namespace std;
float a = 2.1f, b = 4.5f, c = 1.7f,d;
float four = 4.0f, two = 2.0f;
float negative = -1.0f, nb;
float x1, x2;
void printRootMenu()
{
cout << " To see the real roots of aX^2 + bX + c = 0, enter the a, b and c values:" << endl;
cin >> a >> b >> c;
}
void printValues()
{
cout << fixed << setprecision(2);
cout << "X1 = " << x1 << " X2 = " << x2;
}
int main()
{
_asm
{
//b^2
fld b
fld b
fmul
// 4ac
fld four
fld a
fld c
fmul
fmul
// sqrt(b^2 - 4ac)
fsub
fsqrt
fstp d; d = sqrt(b ^ 2 - 4ac)
// -b
fld b
fld negative
fmul
fstp nb
// -b + sqrt(b^2 - 4ac)
fld nb
fld d
fadd
// -b + sqrt(b^2 - 4ac)/2a
fld a
fld two
fmul
fdiv
fstp x1; x1 = -b + sqrt(b ^ 2 - 4ac)
fld nb
fld d
fsub
fld a
fld two
fmul
fdiv
fstp x2;
call printValues
}
return 0;
}