on line 58 what is the work of "sqrt"?
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
|
#include<iostream>
#include<math.h>
using namespace std;
class math
{
public:
int menu,l,w,r;
int circle, re;
int tri,tri2,tri3;
int s;
int area;
math()
{
menu = 0;
l = 0;
w = 0;
tri = 0;
tri2 = 0;
tri3 = 0;
circle = 0;
re = 0;
s = 0;
area = 0;
}
void output()
{
cout << "\t\t\t***Menu***" << endl;
cout << "\t\t\t1.Area of Square" << endl << "\t\t\t2.Area of Circle\n\t\t\t3.Area of Triangle\n";
cout << "\t\t\t"; cin >> menu; cout << "\n\n\n";
if (menu == 1)
{
cout << "Enter Length: "; cin >> l;
cout << endl << "Enter width: "; cin >> w;
r = l*w;
cout << endl <<"Answer is:"<< r;
}
else if (menu == 2)
{
cout << "Enter radious of circle: "; cin >> circle;
re = 3.14*circle*circle;
cout << re;
}
else if (menu == 3)
{
cout << "Enter three sides of triangle: "; cin >> tri>>tri2>>tri3;
}
s = (tri + tri2 + tri3) / 2;
area = sqrt(s*(s - tri)*(s - tri2)*(s - tri3));
cout <<"Answer is:"<< area;
}
};
void main()
{
math m1;
m1.output();
cout << endl;
}
|
Last edited on