• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

campos20 May 19th, 2020 1,065 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <stdio.h>
2. #include <stdlib.h>
3. #include <math.h>
4.
6. // Autor: Alexandre Campos
7.
8. // Funcao de leitura de inteiros
9. int le_numero(){
11.
12.     printf("Digite um numero\n");
14.
16. }
17.
18. // Calcula o delta de acordo com delta = b * b - 4 * a * c
19. int calculo_do_delta(int a, int b, int c){
20.     return b * b - 4 * a * c;
21. }
22.
23. int main()
24. {
25.     // Declaracao
26.     int a, b, c, delta;
27.     double x1, x2;
28.
30.     a = le_numero();
31.     b = le_numero();
32.     c = le_numero();
33.
34.     // Calculo do delta
35.     delta = calculo_do_delta(a, b, c);
36.
37.     printf("delta = %d, a = %d\n", delta, a);
38.     if (delta < 0 || a == 0){
39.         printf("Nao existem solucoes.");
40.     } else {
41.         x1 = ((-b + sqrt(delta)) / (2 * a));
42.         x2 = ((-b - sqrt(delta)) / (2 * a));
43.
44.         printf("As raizes sao %lf e %lf\n", x1, x2);
45.     }
46.
47.     return 0;
48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top