我的开关盒有什么问题?

EGP*_*EGP 0 c c++

它会自动执行默认设置,而不是我的任何情况.知道我做错了什么吗?

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

int main ()
{

    float x,y,z,p,a,h;
    int d;

    printf ("\n This program calculates Perimeter, Area, or Hypotenuse of a right triangle based on user choice\n\n\n\n");

    /* Prompt user to select which calculation is to be performed */

    printf ("If you would like to calculate Perimeter, type P\nIf you would like to calculate Area, type A\nIf you would like to calculate 
    Hypotenuse, type H\n\n") ;

    scanf ("%f,%f,%f",&p,&a,&h);


    switch(d)
    {
        case('p'):
            printf("/n You have chosen to do a perimeter calculation/n");
            printf("/n Input the two side lengths of the right triangle separated by a space/n");

            scanf("%f,%f",&x,&y);
            z = pow (x,2) + pow (y,2);
            p = x + y + z;

            printf("\nLength of side A entered=%f\n",x);
            printf("\nLength of side B entered=%f\n",y);
            printf("\nCalculated Perimeter=%f\n",p);

            break;


        case('a'):
            printf("/n You have chosen to do an area calculation/n");
            printf("/n Input the two side lengths of the right triangle separated by a space/n");

            scanf("%f,%f",&x,&y);
            z = pow(x,2) + pow(y,2);
            p = x + y + z;
            a = (x * y) / 2;

            printf("\nLength of side A entered=%f\n",x);
            printf("\nLength of side B entered=%f\n",y);
            printf("\nCalculated area=%f\n",a);

            break;


        case('h'):

            printf("/n You have chosen to do a hypotenuse calculation/n");
            printf("/n Input the two side lengths of the right triangle separated by a space/n");

            scanf("%f,%f",&x,&y);
            z = pow (x,2) + pow (y,2);

            printf("\nLength of side A entered=%f\n",x);
            printf("\nLength of side B entered=%f\n",y);
            printf("\nCalculated Hypotenuse=%f\n",z);

            break;

            default:

                printf("/n wow...how did that even happen. Please put in a valid letter next time. /n");
    }
}
Run Code Online (Sandbox Code Playgroud)

Jam*_*lis 8

您永远不会分配任何值,d因此它是未初始化的.