Pages

Wednesday, December 7, 2011

C Programming to find slope between any two points


/* to calculate slope between two points */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    float x1,y1,x2,y2,m;
    printf("Enter (x1,y1); seperated by space: ");
    scanf("%f%f",&x1,&y1);
    printf("Enter (x2,y2); seperated by space: ");
    scanf("%f%f",&x2,&y2);
    m=(y2-y1)/(x2-x1);
    printf("The slope between two points is: %f",m);
    system("pause");
    return 0;
}

No comments:

Post a Comment