Write a program that reads six real values a, b, c, u, v, w and then displays the solution of the following equations:
$$a*X + b*Y + c = 0$$
$$u*X + v*Y + w = 0$$


Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    double a, b, c, u, v, w , x ,y;
    printf("Enter 6 reals: ");
    scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &u, &v, &w);
    
    if(a!=0 && (-u*b/a + v) !=0)
    {
        y= (c*u/a-w)/(-u*b/a + v);
        x= (-b*y - c) / a;
    
        printf("x= %.2lf, Y=%.2lf\n",x,y);
    }
    else
        printf("No solution\n");
    
    return 0;
}
 

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Asymptotic Analysis 21