why different answers for this equation
* Write a program that checks whether the equation
(x+y)^2 = x^2 + 2xy + y^2
* is true for all double values. If you find any two values for
* which the equation is not true, then explain why this is so.
*/
#include <stdio.h>
#include <stdlib.h>
int main() {
double x, y, LeftEq, RightEq;
/*Input*/
printf("INPUT");
printf("\n=====\n");
printf("Enter double value for x: ");
scanf("%lf", &x);
printf("Enter double value for y: ");
scanf("%lf", &y);
/*End of Input*/
/*Assign the 2 equations to 2 variables*/
LeftEq = (x+y) * (x+y);
RightEq = (x*x) + (2*x*y) + (y*y);
/*Display Results*/
printf("\n\nCHECK and COMPARE");
printf("\n=================\n");
printf("The EQUATION (X+Y)^2 = %10.13f\n", LeftEq);
/*Conditions to compare the 2 equations*/
if(LeftEq == RightEq)
printf("\n.........has the same value as.........\n\n");
else if(LeftEq != RightEq)
printf("\n.........has a different value from.........\n\n");
else
printf("Invalid values obtained!!!");
/*stop comparing*/
printf("The EQUATION (X^2 + 2XY + Y^2) = %10.13f\n", RightEq);
printf("\n");
/* end of display */
return EXIT_SUCCESS;
}