Program to find slope of a line | C ++ program for slope of line ; function to find the slope of a straight line ; driver code to check the above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; float slope ( float x1 , float y1 , float x2 , float y2 ) { if ( x1 == x2 ) return INT_MAX ; return ( y2 - y1 ) / ( x2 - x1 ) ; } int main ( ) { float x1 = 4 , y1 = 2 ; float x2 = 2 , y2 = 5 ; cout << " Slope ▁ is : ▁ " << slope ( x1 , y1 , x2 , y2 ) ; return 0 ; }