Advertisement
FoxTuGa

Forma Resolv. - <Old>

May 8th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h> 
  2. #include <math.h>
  3.  
  4. double a, b, c;
  5. float xp, xn, z;
  6.  
  7. int main()
  8. {
  9.     printf("                                                          Leandro Soares");
  10.  
  11.     printf("\n a? : "); // inserir o a
  12.     scanf("%lf", &a);
  13.  
  14.     printf(" b? : "); // inserir o b
  15.     scanf("%lf", &b);
  16.  
  17.     printf(" c? : "); // inserir o c
  18.     scanf("%lf", &c);
  19.  
  20.     z = pow(b, 2) - 4 * a * c;
  21.  
  22.     if(z < 0)
  23.     {  
  24.         printf("\n\n Raizes nao reais \n\n");
  25.         return 0;
  26.     }
  27.  
  28.    
  29.     xp = ( -b + sqrt( z ) ) / 2 * a;
  30.  
  31.     xn = ( -b - sqrt( z ) ) / 2 * a;
  32.  
  33.  
  34.     printf(" x = %f e %f\n\n", xp, xn); // output x positivo e x negativo
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement