Professional Documents
Culture Documents
Upperlower I Quad
Upperlower I Quad
Upperlower I Quad
#include <bits/stdc++.h>
using namespace std;
int d = b * b - 4 * a * c;
double sqrt_val = sqrt(abs(d));
if (d > 0) {
cout << "Roots are real and different \n";
cout << (double)(-b + sqrt_val) / (2 * a) << "\n"
<< (double)(-b - sqrt_val) / (2 * a);
}
else if (d == 0) {
cout << "Roots are real and same \n";
cout << -(double)b / (2 * a);
}
else // d < 0
{
cout << "Roots are complex \n";
cout << -(double)b / (2 * a) << " + i" << sqrt_val / (2 * a)
<< "\n"
<< -(double)b / (2 * a) << " - i" << sqrt_val / (2 * a) ;
}
}
// Driver code
int main()
{
int a = 1, b = -7, c = 12;
// Function call
findRoots(a, b, c);
return 0;
}
=========================
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int a,b,c; // constants of equation
float x1,x2; //roots
cout<<"Enter value of a: ";
cin>>a;
cout<<"Enter value of b: ";
cin>>b;
cout<<"Enter value of c: ";
cin>>c;
int D;
D= b*b - 4*a*c; // determinant
if(D>=0){ //nature of roots
if(D==0)
cout<<"Roots are real and equal: ";
else
cout<<"Roots are real and distinct: ";
x1=(-b+ sqrt(D))/(2*a); // roots calculation by quadratic
formula
x2=(-b- sqrt(D))/(2*a);
cout<<x1<<", "<<x2;
}
else
cout<<"Roots are imaginary!";
return 0;
}
=============================
#include <iostream>
using namespace std;
}
cout<<"\n The string in upper case: "<< str;
}
int main()
{
string str;
cout<<"Enter the string ";
getline(cin,str);
lower_string(str); //function call to convert to lowercase
upper_string(str); //function call to convert to uppercase
return 0;
}