TCS
Company
Programming
Cliff and Radar
Two cliffs of lengths X and Y join at one end and enclose a body of water. The angle between the cliffs, phi, is known. A radar is installed at the point where the cliffs are joined. It has a range of m where m < X and m < Y. Calculate the area of the water enclosed between the cliffs which cannot be scanned by the radar and the distance between the end points of two cliffs.
Fig:Cliff and Radar
Input Format:
First line contains length of cliff AB, denoted by X in meters
Second line contains length of cliff AC, denoted by Y in meters
Third line contains range of radar, denoted by m in meters
Fourth line contains angle BAC in degrees, denoted by Φ (phi)
Output Format:
On first line, print the area enclosed between the cliffs that cannot be scanned by the radar in square meters
On second line, print the distance between end points of two cliffs in meters
Constraints:
X > 0
Y > 0
0 < m < X and 0 < m < Y
Φ (phi) > 0
Calculations should be done upto 11-digit precision, but output values should be printed upto 5 decimal places
Read Solution (Total 2)
-
- #include
#include
#include
#define pi 3.14
int main()
{
double x,y,m,p,dist,ar,third,s,t;
clrscr();
printf("enter x:n");
scanf("%lf",&x);
printf("enter y:n");
scanf("%lf",&y);
printf("enter mn");
scanf("%lf",&m);
printf("enter angle:n");
scanf("%lf",&p);
dist =sqrt((x*x)+(y*y)-(2*x*y*cos(p*(pi/180))));
printf("distance bw cliffs is::%lfn",dist);
s=(x+y+dist)/2;
t=(m*m)*p*(0.5)*(pi/180);
third=sqrt(s*(s-x)*(s-y)*(s-dist));
ar=(third-t);
printf("area without radar is::%lfn",ar);
getch();
return 0;
} - 9 years agoHelpfull: Yes(1) No(0)
- tcs gives programs to solve in apti?Is it true?
- 9 years agoHelpfull: Yes(0) No(0)
TCS Other Question