Problem with delta output<0

Asked

Viewed 231 times

1

Good evening, I am having trouble with the output of my program which printed on the screen the roots of the second degree equation. When I go to the condition of:

if (delta<0) //Condicao caso o delta seja menor que zero
{  
    printf("Sem raiz"); //Impressao de um resultado invalido
}

The output of the program is as:

Sem raiz0.0000
0.0000
  • 1

    Only with this it is not possible to help you, put relevant parts of the program: http://answall.com/help/mcve

  • 1

    Only with this part of the code gets complicated. Probably the part that prints the result should be after if (and outside of Else)

1 answer

1


Just the part you posted about the code, it’s hard to help. The impression is that one is missing else to display results only if delta is zero or more.

Something like that:

if (delta<0) //Condicao caso o delta seja menor que zero
{  
    printf("Sem raiz"); //Impressao de um resultado invalido
}
else
{
    // aqui vai o printf que mostra as raízes, que só aparecerão se
    // a condição anterior for falsa, graças ao else.
}

Browser other questions tagged

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