lundi 25 septembre 2017

I need to use switch case within if else for C

I wanted for people to type extra value to select if they will get 1 answer or 2answer So this is what i built if(root <0){ printf("Error");

}
else{
    printf("Type 0 for both roots or 1 for one roots ");
    scanf("%d",result);

    switch(result){
    case 0:
    printf("The calculation of quadratic equation is %lf and %lf",cal, cal2);
    break;
    case 1:
    printf("One of the calculation of quadratic equation is %lf",cal);
    break;
    default:
    printf("Hello");
    break;
    }

}

Aucun commentaire:

Enregistrer un commentaire