#include #include // use #gcc -lm to compile while using math.h int main() { float x1=0,y1=0,x2=0,y2=0,k=0; printf("Enter the coordinates of point A in format: x1,y1 "); scanf("%f,%f",&x1,&y1); printf("Enter the coordinates of point B in format: x2,y2 "); scanf("%f,%f",&x2,&y2); printf("enter the value of K (K>=0)"); scanf("%f",&k); float x=0,y=0; /* Now let P(x,y) divides AB in ratio 1:k ** * Then x = x1 + (|AB|/(k+1))(cos (slope)) ie - x = x1 + (|AB|/(k+1))* ((x2-x1)/|AB|) ** * hence , x = x1 + (1/(k+1)) * (x2-x1); ** * similarly , y = y1 + (1/(k+1)) * (y2-y1); ** */ x = x1 + (1/(k+1))* (x2-x1); y = y1 + (1/(k+1))* (y2-y1); printf("The X coordinate is %f\n",x); printf("The Y coordinate is %f\n",y); return 0; }