My program does not work [closed]

-4

At the moment of executing my program it works, but in a trapezoid and in a rectangle it gets stuck. I've checked it and I do not know what the fault is.

This is the code.

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{

***case 5: printf("Area trapecio\n");
float Atrap, Bmayor, Bmenor, htrap; 
printf("introducir Bmayor\n");   
scanf("%f",&Bmayor); 
printf("introducir Bmenor\n");   
scanf("%f",&Bmenor); 
printf("introducir htrap\n");   
scanf("%f",htrap); Atrap=htrap*((Bmayor+Bmenor)/2);   
printf("Area del trapecio es=%f\n",Atrap);
      break;

    case 6:
        printf("Area del rectangulo\n");
        int Base,Altura,Arecta;
        printf("Introducir Base\n");
        scanf("%d",&Base);
        printf("Introdcir Altura\n");
        scanf("%d",Altura);
        Arecta= Base*Altura;
        printf("Area del rectangulo es=%d\n",Arecta);
        break;***


      }

getch();
return(0);
}
    
asked by Zoeck Ecko Ccortes 11.09.2017 в 00:22
source

1 answer

2
scanf("%f",&Bmenor); 
//         ^ -> correcto

scanf("%f", htrap);
//         ^ -> error

The program fails simply because scanf expects to receive a pointer (ie, a memory address) and you are passing it a raw variable .

scanf("%f",&htrap);
    
answered by 11.09.2017 в 17:39