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.

Write a c program to calculate the distance between the teo pints

+10 votes
asked Feb 25, 2022 by Siva Naidu Dammalapati (230 points)

1 Answer

+2 votes
answered Feb 25, 2022 by Hari Haran__2164 (180 points)
  1. #include<stdio.h>  
  2. #include<math.h>  
  3.   
  4. int main()  
  5. {  
  6.     float x1, y1, x2, y2, distance;  
  7.   
  8.     printf("Enter point 1 (x1, y1)\n");  
  9.     scanf("%f%f", &x1, &y1);  
  10.   
  11.     printf("Enter point 2 (x2, y2)\n");  
  12.     scanf("%f%f", &x2, &y2);  
  13.   
  14.     distance = sqrt( (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) );  
  15.   
  16.     printf("Distance between (%0.2f, %0.2f) and (%0.2f, %0.2f) is %0.2f\n", x1, y1, x2, y2, distance);  
  17.   
  18.     return 0;  
  19. }  
commented Mar 5, 2022 by Gopi Krishna (400 points)
can i know y you put %0.2f
is %0.2f is Applicable
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.
...