#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ESP 0.0001
#define F(x) 0.2*(x)*(x) - (x) + 0.8
#define G(x) 0.3*(x)*(y)*(y) - (y) + 0.7
#define X(x,y) 0.2*(x)*(x) + 0.8
#define Y(x,y) 0.3*(x)*(y)*(y) + 0.7
#define F1(x,y) 0.4*(x)
#define F2(x,y) 0
#define G1(x,y) 0.3*(y)*(y)
#define G2(x,y) 0.6*(x)*(y)
void main()
{
float x1,y1,y2,x2,x,y;
int i=1;
clrscr();
do
{
printf("\nEnter the value of x: ");
scanf("%f",&x);
printf("\nEnter the value of y: ");
scanf("%f",&y);
}while(fabs(F1(x,y)+F2(x,y)) > 1 && fabs(G1(x,y)+G2(x,y)) > 1);
x1=X(x,y);
y1=Y(x,y);
printf("\n x = %f",x1);
printf("\n y = %f",y1);
printf("\n\n");
do
{
x2=X(x1,y1);
y2=Y(x1,y1);
if(fabs(x1-x2)<ESP && fabs(y1-y2)<ESP)
{
printf("\n\nREAL ROOT1 = %.3f",x1);
printf("\n\nREAL ROOT2 = %.3f",y1);
i=0;
}
else
{
x1=x2;
y1=y2;
}
if(i==1)
{
printf("\n x = %f",x1);
printf("\n y = %f",y1);
printf("\n\n");
}
}while(i!=0);
getch();
}
/*
____________________________
OUT PUT
____________________________
Enter the value of x:
Enter the value of y:
x = 0.850000
y = 0.737500
x = 0.944500
y = 0.838696
x = 0.978416
y = 0.899312
x = 0.991460
y = 0.937392
x = 0.996598
y = 0.961360
x = 0.998642
y = 0.976321
x = 0.999457
y = 0.985572
x = 0.999783
y = 0.991247
x = 0.999913
y = 0.994707
x = 0.999965
y = 0.996807
x = 0.999986
y = 0.998077
x = 0.999994
y = 0.998843
x = 0.999998
y = 0.999305
x = 0.999999
y = 0.999582
x = 1.000000
y = 0.999749
x = 1.000000
y = 0.999849
REAL ROOT1 = 1.000
REAL ROOT2 = 1.000
*/