Archive:Roots of an equation: Difference between revisions
Appearance
wikademia>Milan New page: <pre>solution of degree 2 eqn #include<stdio.h> #include<conio.h> void main() { float a1,b1,c1,a2,b2,c2,x,y; clrscr(); printf("enter co-eff's of both the equations"); scanf("%f%f%f%f%f%f"... |
m Idea moved page Roots of an equation to Archive:Roots of an equation |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
< | <source lang="c">//solution of degree 2 eqn | ||
#include<stdio.h> | #include<stdio.h> | ||
| Line 5: | Line 5: | ||
void main() | void main() | ||
{ | { | ||
float a1,b1,c1,a2,b2,c2,x,y; | float a1,b1,c1,a2,b2,c2,x,y; | ||
clrscr(); | clrscr(); | ||
printf("enter co-eff's of both the equations"); | printf("enter co-eff's of both the equations"); | ||
scanf("%f%f%f%f%f%f",&a1,&b1,&c1,&a2,&b2,&c2); | scanf("%f%f%f%f%f%f",&a1,&b1,&c1,&a2,&b2,&c2); | ||
y=((c2*a1)-(c1*a2))/((a1*b2)-(a2*b1)); | y=((c2*a1)-(c1*a2))/((a1*b2)-(a2*b1)); | ||
x=((c1*b2)-(c2*b1))/((a1*b2)-(a2*b1)); | x=((c1*b2)-(c2*b1))/((a1*b2)-(a2*b1)); | ||
printf("x=%f\n y=%f\n",x,y); | printf("x=%f\n y=%f\n",x,y); | ||
getch(); | getch(); | ||
} | } | ||
</source> | |||
[[Category:C source code examples]] | |||
Latest revision as of 19:15, 29 September 2026
<source lang="c">//solution of degree 2 eqn
- include<stdio.h>
- include<conio.h>
void main() {
float a1,b1,c1,a2,b2,c2,x,y;
clrscr();
printf("enter co-eff's of both the equations");
scanf("%f%f%f%f%f%f",&a1,&b1,&c1,&a2,&b2,&c2);
y=((c2*a1)-(c1*a2))/((a1*b2)-(a2*b1));
x=((c1*b2)-(c2*b1))/((a1*b2)-(a2*b1));
printf("x=%f\n y=%f\n",x,y);
getch();
} </source>