Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
Write a c program to calculate the distance between the teo pints
+10
votes
asked
Feb 25, 2022
by
Siva Naidu Dammalapati
(
230
points)
Please
log in
or register to answer this question.
1 Answer
+2
votes
answered
Feb 25, 2022
by
Hari Haran__2164
(
180
points)
#include<stdio.h>
#include<math.h>
int
main()
{
float
x1, y1, x2, y2, distance;
printf(
"Enter point 1 (x1, y1)\n"
);
scanf(
"%f%f"
, &x1, &y1);
printf(
"Enter point 2 (x2, y2)\n"
);
scanf(
"%f%f"
, &x2, &y2);
distance = sqrt( (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) );
printf(
"Distance between (%0.2f, %0.2f) and (%0.2f, %0.2f) is %0.2f\n"
, x1, y1, x2, y2, distance);
return
0;
}
commented
Mar 5, 2022
by
Gopi Krishna
(
400
points)
can i know y you put %0.2f
is %0.2f is Applicable
Please
log in
or register to add a comment.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...