bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

luc063.c (1192B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 08 Feb 2026
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* The X and Y coordinates of 10 different points are entered through the keyboard. Write a program to find the distance of last point from the first point (sum of distances between consecutive points).
      9 */
     10 
     11 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(i) */
     12 
     13 /* This file is auto-generated by a bot. */
     14 /* This code is not compiled; it is for reference only. */
     15 
     16 
     17 #include <stdio.h>
     18 #include <math.h>
     19 #include <stdlib.h>
     20 
     21 int main()
     22 {
     23     double x[10], y[10];
     24     double total_distance = 0.0;
     25     int i;
     26 
     27     printf("Enter coordinates (x, y) for 10 points:\n");
     28     for (i = 0; i < 10; i++)
     29     {
     30         printf("Point %d: ", i + 1);
     31         scanf("%lf %lf", &x[i], &y[i]);
     32     }
     33 
     34     // Sum of distances between consecutive points P(i) and P(i+1)
     35     for (i = 0; i < 9; i++)
     36     {
     37         double dx = x[i+1] - x[i];
     38         double dy = y[i+1] - y[i];
     39         total_distance += sqrt(dx*dx + dy*dy);
     40     }
     41 
     42     printf("\nTotal distance from first to last point: %.2f\n", total_distance);
     43 
     44     return 0;
     45 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror