Labels
- 2-3Tree (1)
- 2-3Tree@ADS(EXP3) (1)
- ADS (6)
- ADS@Exp1 (1)
- ADS@Exp2 (1)
- ADS@Exp3 (1)
- ADSLAB (1)
- AVL TREE (2)
- AVL-Tree@ADS(EXP2) (1)
- B-Tech (1)
- CNS (1)
- cp for area of triangle (1)
- cpexp1a (1)
- CSE (2)
- CSE FOSS (1)
- CUT) (1)
- DAA (1)
- DECIMAL TO BINARY (1)
- FOSS (4)
- FOSS LAB SYLLABUS (1)
- FOSS@EXP2(CAT (1)
- FOSS@EXP3 (1)
- HASHING (2)
- JNTUK@ADS LAB (3)
- JNTUKR13REGULATION (1)
- ONES COMPLEMENT (1)
- PASTE (1)
- R13 FOSS LAB (1)
- SED (FOSS command) (1)
- SHELL (foss COMMAND) (1)
- TWO'S COMPLEMENT (1)
a)
|
Write a C Program to calculate the
area of triangle using the formula
area = ( s (s-a) (s-b)(s-c))1/2 where
s= (a+b+c)/2
|
Program:
[bkrishna@localhost cp1]$ vi areatri.c
#include<stdio.h>
#include<math.h>
main()
{
float a,b,c,s,area;
printf("Enter sides of triangle
(a,b,c values) :");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of the traingle
(whose sides are %f %f %f) is: %f\n",a,b,c,area);
}
|
|
Output:
[bkrishna@localhost cp1]$ cc areatri.c
-lm
[bkrishna@localhost cp1]$ ./a.out
Enter sides of triangle (a,b,c values)
:3 4 5
Area of the traingle (whose sides are
3.000000 4.000000 5.000000) is: 6.000000
|
Labels:
cp for area of triangle,
cpexp1a
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment