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)
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...