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 distance between consecutive points).
#include math.h(include arrows)
void main()
{
float dis(int,int);
int arr[10][2];
int i,j;
float sum;
for(i=0;i<10;i++)
{
for(j=0;j<2;j++)
{
printf("\nKey in the [%d][%d]) value",i+1,j+1);
scanf("%d",&arr[i][j]);
}
}
for(i=0;i<10;i++)
sum=sum+dis(arr[i][0],arr[i][1]);
printf("\nThe sum of the distance is %f",sum);
}
float dis(int a,int b)
{
float c;
c=sqrt((a*a)+(b*b));
return(c);
}
Subscribe to:
Post Comments (Atom)
its very complicated for the beginers...can you make it more easier to understand..???
ReplyDelete