Using this program user can find the length of a straight line formed by two end points, whose
coordinates would be given as inputs.
FORMULA:-√
(( y2− y1)² +( x2− x1)²)Program:
//C Program to Find the Length of a Straight Line Formed by Two End Points By Slashmycode.com
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
void
main()
{
float
x1,x2,y1,y2,line_len;
clrscr();
printf("Enter
the x co-ordinate of the first point");
scanf("%f",&x1);
printf("Enter
the y co-ordinate of the first point");
scanf("%f",&y1);
printf("Enter
the x co-ordinate of the second point");
scanf("%f",&x2);
printf("Enter
the y co-ordinate of the second point");
scanf("%f",&y2);
line_len=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
printf("the
length of the line is %f",line_len);
//C Program to Find the Length of a Straight Line Formed by Two End Points By Slashmycode.com
//C Program to Find the Length of a Straight Line Formed by Two End Points By Slashmycode.com
getch();
}
Output:
Algorithm:
- Start
- Define x1,x2,y1,y2,d
- Accept the value of x1,y1,x2,y2
- Calculate
- d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
- Print value of d
- Stop
Flowchart:
Click on image to enlarge |
Pls can you put the algorithm
ReplyDeleteits given
DeleteAlgorithm:
1 Start
2 Define x1,x2,y1,y2,d
3 Accept the value of x1,y1,x2,y2
4 Calculate
d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
5 Print value of d
6 Stop