Skip to main content

Area of a triangle given as follows: A= square root of s(s-a)(s-b)(s-c) where a,b,c are the sides of a triangle and 2s=a+b+c. Write a C program to calculate the area of a triangle.


Answer:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();



float a,b,c,S,A;
printf("ENTER THE THREE SIDES OF A TRIANGLE:  ");
scanf("%f%f%f",&a,&b,&c);
S=(a+b+c)/2;
A=sqrt(S*(S-a)*(S-b)*(S-c));
printf("\nArea of the triangle: %.2f",A);
getch();
}

Sample output:
ENTER THE THREE SIDES OF A TRIANGLE: 10 12 14

Area of the triangle=58.79

Popular posts from this blog

Draw the basic organization of computer

Answer:                 The basic organization of computer__ Input Unit: ·          It accepts (or reads) instructions and data from outside. ·          It converts these instructions and data in computer acceptable form ·          It supplies the converted instructions and data to the computer system for further processing. Central Processing Unit (CPU): Control Unit: Control unit of a computer system manages and coordinates the operations of all other components of the computer system. Arithmetic Logic Unit(ALU): Arithmetic logic unit of a computer system is the place, where the actual executions of instruction, takes place during processing operation. Storage Unit: Primary Memory: It is volatile ( loses data on power ...

Describe the four basic data types. How could we extend the range of values they represent?

Answer: The basic four data types are: Data Type Integer Type Character Type Floating Point Type Void Type signed int short int long int unsigned unsigned int unsigned short int unsigned long int char signed char unsigned char float double long double