Hello, I have a little problem with "float" and "double". The problem is that in "resultado", always appears a integral number, also when the division or the root result is decimal. I have tried to use float and double, and the result is the same. I donīt know why is happening that, in theory, "float" and "double" work with decimals.
Code:
int main(int argc, char* argv[])
{
int a,b,c;
double raiz, resultado;
//[..]
if(c==0 & b!=0 & a!=0){
printf("x=0");
resultado = ((-b)/a);
printf("x=%d", resultado);
}
if (b==0 & a!=0){
raiz = ((-c)/a);
if (raiz<0){
printf("Sin solucion (raiz negativa)");
}
else{
resultado=sqrt(raiz);
printf("El resultado es: %d", resultado);
}
}
Thanks,