You are on page 1of 2

INPUT

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float a, b, c, x1, x2, rootanswer;
cout<<"output prepared by VAIBHAV KOTHARE"<<endl;
cout << "Enter the values of a, b and c: "<<endl;
cin >> a >> b >> c;
rootanswer = b*b - 4*a*c;
if (rootanswer > 0) {
x1 = (-b + sqrt(rootanswer)) / (2*a);
x2 = (-b - sqrt(rootanswer)) / (2*a);
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
else if (rootanswer == 0)
{
cout << "the aanswers of the all the roots are same " << endl;
x1 = (-b + sqrt(rootanswer)) / (2*a);
cout << "x1 = x2 =" << x1 << endl;
}
return 0;
}
OUTPUT
Q.2. . Write a C++ program to evaluate the following expressions:
{a+b}* cmd/a-b

INPUT :

#incIude<iostream.fi>
#incIude<conio.h>
ttlnc lusmmalh.fix
int main()
{
irtl a= 22;
int b= 19;
int c= 18;
lni d= SS ;
int e;
cout<<endI<<"Output prepared by VAIBHAV KOTHARE "<<endI;
e = (a+b) 'c+d/a b;
cou1<< endI<< ’Value of{a+ b) "c+d/a b is: ”’<<e<<endI;
getch();
return 0;
}

You might also like