-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1.cpp
More file actions
56 lines (45 loc) · 1.39 KB
/
P1.cpp
File metadata and controls
56 lines (45 loc) · 1.39 KB
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
#include <iostream>
#include <cmath>
using namespace std;
int main(){
//------------------------------------Compund Intrest------------------------------------
// double power;
// double ci,a,p,r,n,t;
// cout<<"Enter the principle value "<<endl;
// cin>>p;
// cout<<"Enter the rate "<< endl;
// cin>>r;
// cout<<"Enter the value of n "<<endl;
// cin>>n;
// cout<<"Enter the time period "<<endl;
// cin>>t;
// a = (1+r/(100*n));
// ci = p*pow(a,n*t);
// cout<<"Value of compound interest is "<< ci<<endl;
//-------------------------------------Quadratic Equation---------------------------------
float a, b, c;
float d, root1, root2;
cout << "Enter value of a: ";
cin >> a;
cout << "Enter value of b: ";
cin >> b;
cout << "Enter value of c: ";
cin >> c;
d = (b * b) - (4 * a * c);
if (d > 0) {
root1 = (-b + sqrt(d)) / (2 * a);
root2 = (-b - sqrt(d)) / (2 * a);
cout << "Roots are real and different\n";
cout << "Root 1 = " << root1 << endl;
cout << "Root 2 = " << root2 << endl;
}
else if (d == 0) {
root1 = -b / (2 * a);
cout << "Roots are real and equal\n";
cout << "Root = " << root1 << endl;
}
else {
cout << "Roots are imaginary (not real)" << endl;
}
return 0;
}