I WAS ASKED TO CODE A PROGRAM IN C WHICH ACCEPTS TWO EQUATIONS OF THE FORM ax+by+c=0 AND SOLVE THEM BY CRAMER'S RULE IN MY LAB.
I DID IT IN THE FOLLOWING WAY.
plzzz include stdio.h and conio.h....................
void main()
{
int a,b,c,l,m,n;
char x,y,z,d,e,f,g,h;
float r,s,t;
clrscr();
printf("Enter two equations of the form ax+by+c , excluding spaces\n");
printf("Enter first equation :- \n");
scanf("%d%c%c%d%c%c%d",&a,&x,&y,&b,&Z,&d,&c);
printf("Enter second equation :- \n");
scanf("%d%c%c%d%c%c%d",&l,&e,&f,&m,&g,&h,&n);
r=(a*m)-(l*b);
if (r==0)
{
printf("the equation is not solvable by cramer's rule");
getch();
}
else
{
s=((c*m)-(b*n))/r;
t=((n*a)-(l*c))/r;
printf("The roots of equations are x = %f , y= %f ",s,t);
getch();
}
}
please tell me if there is some other easy method.........................
No comments:
Post a Comment