본문 바로가기

C언어

[C언어] 삼각형 면적

삼각형의 밑변과 높이를 입력 받아서 삼각형의 면적을 구하여 출력하는 프로그램을 작성하시오.

 

#include <stdio.h>
main()
{
	int w, h;
	float a;
	
	printf("Input width: ");
	scanf("%d", &w);
	printf("Input height: ");
	scanf("%d", &h);
	
	a = w * h / 2.0;
	
	printf("Area: %.2f", a);
}