Write C programs to do the following: 1. Euclidean distance problem: Compute the
ID: 2248666 • Letter: W
Question
Write C programs to do the following: 1. Euclidean distance problem: Compute the Euclidean distance between two points on a 2D plane. Hint: The distance between two points (xi. yi) (x2. y2) on a 2D plane is given by [Hint: Use the math header file #include Note: The two points (xi.yi).6x2 y2) must be input from user using the scanf function] 2. Generate a degree-to-radian table which shows the conversion of angular values from degrees to radians. [Hint: Use the identity rad = 180°] [Hint: Use the macro #define P13.14 159] Note: Degrees to be given as input using scanf inside a for loop and output is radians] 3. Compute the area of a sector of a circle when is the angle in radians between the radii. (Hint: d=r2 / 2 where is in radians) [Note: Both and r to be given as input using scanf function] Compute the volume of a sphere ofradíus. (Hint:V=(4/3)w3) [Hint: Use the macro #define PI 3.14159] Note: Here r is to be given as input using scanf function] 4.Explanation / Answer
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
int d,x1,x2,y1,y2;
printf("Enter value of x1,y1,x2,y2:");
scanf("%d %d %d %d",&x1 ,&y1 ,&x2 &y2);
printf("Enterred points are as below");
printf("(%d,%d)",x1,y1);
printf("(%d,%d)",x2,y2);
d=sqrt(pow((x2-x1),2)+pow((y2-y1),2);
printf("Distance between (x1,y1) and (x2,y2):%d,d);
getch();
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.