Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- float a(){
- float a;
- printf("Podaj wspolczynnik a: \n");
- scanf("%f", &a);
- return a;
- }
- float b(){
- float b;
- printf("Podaj wspolczynnik b: \n");
- scanf("%f", &b);
- return b;
- }
- float c(){
- float c;
- printf("Podaj wspolczynnik c: \n");
- scanf("%f", &c);
- return c;
- }
- float wyznacznik(float d, float e, float f){
- float wynik;
- wynik=pow(e,2)-4*d*f;
- return wynik;
- }
- void dane (){
- a();
- b();
- c();
- }
- void przetworz(){
- float delta,ab,bc,ce,x1,x2,x;
- ab=a();
- bc=b();
- ce=c();
- delta=wyznacznik(ab,bc,ce);
- if (delta<0)
- {
- printf("Rownanie nie posiada rozwiazania w zbiorze liczb rzeczywistych");
- }
- if (delta==0)
- {
- x=(-bc)/2*ab;
- printf("Rozwiazaniem jest X=%f",x);
- }
- if (delta>0)
- {
- x1=(-bc-sqrt(delta))/2*ab;
- x2=(-bc+sqrt(delta))/2*ab;
- printf("Rozwiazaniem jest X1= %f lub X2= %f", x1,x2);
- }}
- main(){
- printf("*********************** Rownania kwadratowe ***********************\n");
- dane();
- przetworz();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement