RESPONDER UNA PREGUNTA

Si para responder la pregunta, crees necesario enviar un archivo adjunto, puedes hacerlo a traves del correo [email protected]

    Pregunta:  65843 - SWICH COMPUESTO (CON DOS VARIABLES) EN C
Autor:  Alejandro Caro
como hago un switch compuesto (con dos variables) en c , cuando lo intento me tira error

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
double a, b, c, r1, r2, real, compleja, d; //Declaración de variables
int varseleccion;
printf("a = "); printf("b = "); printf("c = ");
printf("Ecuaci¢n: %e.x^2 + %e.x + %e", a, b, c);

switch (varseleccion){ //Ecuación degenerada
case a = 0 && case b = 0: //<-- case label does not reduce to an integer constant
printf("La ecuaci¢n es degenerada");
break;
case a = 0 && case b != 0: //Dos raíces reales iguales //<-- case label does not reduce to an integer constant
r1 = -c / b;
//r2 = r1
printf("r1 = r2 = %e", r1);
break;
default:
d = pow(b,2) - 4 * a * c;

switch (varseleccion){
case d >= 0: //Dos raíces reales diferentes //<-- case label does not reduce to an integer constant
r1 = (pow(-b + (pow(b,2) - 4 * a * c), (1 / 2))) / (2 * a);
r2 = (pow(-b - (pow(b,2) - 4 * a * c), (1 / 2))) / (2 * a);
printf("r1 = %e", r1);
printf("r2 = %e", r2);
break;
default: //Dos raíces complejas conjugadas
real = -b / (2 * a);
compleja = ((pow(b,2) + 4 * a * c), ((1 / 2))) / (2 * a); //<-- warning: value computed is not used|
printf("r1 = %e + %e.i", real, compleja);
printf("r2 = %e + %e.i", real, compleja);
}
}
return 0;
}


Nombre
Apellidos
Correo
Comentarios