Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     int a,b,c;
  8.     float x1, x2;
  9.     double d;
  10.     printf("Input a: ");
  11.     scanf("%d", &a);
  12.     printf("Input b: ");
  13.     scanf("%d", &b);
  14.     printf("Input c: ");
  15.     scanf("%d", &c);
  16.     d = b*b-4*a*c;
  17.     if (d >= 0)
  18.     {
  19.         if (d == 0)
  20.         {
  21.         x1 = (-1*b)/(2*a);
  22.             printf("x1 = %f", x1);
  23.         }
  24.         else
  25.         {
  26.             x1 = (-1*b+sqrt(d))/(2*a);
  27.             x2 = (-1*b-sqrt(d))/(2*a);
  28.             printf("x1= %f x2= %f", x1, x2);
  29.         }
  30.     }
  31.     else
  32.     {
  33.         printf("Net korney");
  34.     }
  35.     getch();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement