C program that calculate the rate of change and indicate if it is increasing or decreasing
Posted by Samath
Last Updated: June 03, 2015

Write a C program that receives as input 4 parameters named x1 ,x2, y1 ,y2 representing continuous points of a linear equation(f(x)=x*m+b). Calculate the rate of change and also indicate if it is increasing or decreasing.


int main(int argc, char *argv[])

int x1,x2,y1,y2;
float ans;

printf("Enter first X parameter:"); 

printf("Enter corresponding Y parameter:");

printf("Enter second X parameter:");

printf("Enter corresponding Y parameter:");

ans = (y2-y1)/(x2-x1); 

printf("The rate of change is:%f \n",ans); 

if(ans > 0)
	printf("The equation is increasing. \n");
else if(ans < 0)
	printf("The equation is decreasing. \n");
else if (ans == 0) 
	printf("The equation is not changing. \n");

return 0;