**Ex:**write a C program to find area of triangle. How to write a C program which find area of triangle. C Program To Print area of triangle.

**Input from user:**

Enter the breadth of triangle: 5

Enter the height of triangle: 10

**Expected output:**Area of triangle: 25.0000

2. Use variable b for breadth and h for height of the triangle and a for store area of triangle.

3. In the logic multiply breadth into height and devide it by 2 a=(b*h)/2.

4. Print a(area of triangle) on the output screen.

int main()

{

int b,h;

float a;

printf("Enter the breadth of triangle\n");

scanf("%d",&b);

printf("Enter the height of the triangle\n");

scanf("%d",&h);

a=(b*h)/2;

printf("Area of triangle is %f",a);

return 0;

}

**Step by step descriptive logic of the given program:**

**1. First accept breadth and height of the triangle from user.**

2. Use variable b for breadth and h for height of the triangle and a for store area of triangle.

3. In the logic multiply breadth into height and devide it by 2 a=(b*h)/2.

4. Print a(area of triangle) on the output screen.

**Program:**

**#include<stdio.h>**

int main()

{

int b,h;

float a;

printf("Enter the breadth of triangle\n");

scanf("%d",&b);

printf("Enter the height of the triangle\n");

scanf("%d",&h);

a=(b*h)/2;

printf("Area of triangle is %f",a);

return 0;

}

**Above program shows the following output:**

## No comments:

## Post a Comment

If you have any doubts, please discuss here...