c - Taking user input in switch case -
can take input in switch case ? in here if run code, asks value of 'a' returns area 0. if define value of 'a' while declaring or anywhere outside of switch case, returns correct value.
double a, area; switch(ch) { case 1: printf("equilateral triangle \n"); printf("value of side \n"); scanf("%f",&a); area= 0.433*a*a; printf("\n %f", area); break; default : break; }
yes can. getting wrong result because using wrong specifier double. use %lf instead (in scanf).
see running code here.
Comments
Post a Comment