How can i use decimal number for "base" "height"?

when i tried to use decimal numbers the program skip the next step and go directly to the result

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <conio.h>
main()
{
int b,h,a;
system("cls");
printf("Base del rectangulo=");
scanf("%d",&b);
printf("Altura del rectangulo=");
scanf("%d",&h);
a=float(b)*float(h);
printf("Area=%d",a);
printf("\n\HECHO POR ANDRES EMILIANO JARA CANO 2B");
getch();
return 0;

}
Last edited on
You're writing in C. If it's meant to be C++, then just do it in C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using std::cout;
using std::cin;

int main()
{
  float b,h,a;

  cout << "Base del rectangulo=";
  cin >> b;

  cout << "Altura del rectangulo=";
  cin >> h;

  a=b * h;

  cout << "Area = " << a;
  cout <<"\n POR ANDRES EMILIANO JARA CANO 2B";
}

Topic archived. No new replies allowed.