Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<math.h>
- int main()
- {
- int a, b, c;
- float x1, x2, delta, p;
- printf("Podaj wartosc a:\n");
- scanf("%d", &a);
- printf("Podaj wartosc b: \n");
- scanf("%d", &b);
- printf("Podaj wartosc c: \n");
- scanf("%d", &c);
- if( a != 0)
- {
- delta = ( b * b) - (4 * a * c);
- if(delta > 0)
- {
- p = sqrt(delta);
- x1 = (b *(-1) + p) / (2 * a);
- x2 = (b *(-1) - p) / (2 * a);
- printf("Funkcja kwadratowa ma dwa miejsca zerowe x1=%f i x2=%f \n", x1,x2);
- } else if( delta == 0)
- {
- x1 = (b * (-1)) / (2 *a);
- printf("Funkcja kwadratowa ma jedno miejsce zerowe x1 = %f \n", x1);
- }else
- {
- printf("Delta jest ujemna podana funkcja kwadratowa nie ma miejsc zerowych \n");
- }
- }else
- {
- printf("Podana funkcja kwadratowa nie istnieje \n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement