I don’t know if my pseudo code is right

Asked

Viewed 74 times

0

  1. Make a pseudocode and flowchart that enters with 3 values and generates the 2 degree equation, check the possible roots. Delta= (b*b) -(4*a*c), check whether Delta is greater than 0, less than 0 or equal to 0.

I did it like this, I don’t know if it’s all right.

Inicio_algoritmo

      Declare: A, B, C e  D numéricos 
Escreva: “Digite três valores para verificar se o delta é maior que 0, menor que 0 ou igual a 0”
Leia: A, B, C 
D <- ((b*b) -(4*a*c))
Se (D > 0) 
Escreva “X1 = “ (-B + RaizQ(D)/ (2*A),  “X2 = “ (-B – RaizQ(D)/(2*A) 

Senão_se (D == 0)
Escreva “X1 = “ (-B + RaizQ(D)/ (2*A),  “X2 = “ (-B – RaizQ(D)(/2*A)

Senão
Escreva “ Não há raízes, delta menor que 0. ” 

Fim_algoritmo
  • The logic is right, as for the syntax of the commands I have my doubts.

  • One detail: if delta is zero, the square root is also zero and the two roots are equal to -B / (2*A) (would not need to calculate the square root, and could do the account only once before writing)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.