Friday, August 17, 2018

IO 3

        Problem Description

Write a program to calculate the perimeter of a triangle using Heros formula

Use the  Following Formula:

s=(a+b+c)/2area=sqrt(s*(s-a)*(s-b)*(s-c))

Input and Output Format:

Refer sample input and output for formatting specification.

All float values are displayed correct to 2 decimal places.

All text in bold corresponds to input and the rest corresponds to output.



CODING ARENA::

#include <stdio.h>
#include<math.h>
int main()
{
  float a,b,c,s,area;
  scanf("%f%f%f",&a,&b,&c);
  s=(a+b+c)/2;
  area=sqrt(s*(s-a)*(s-b)*(s-c));
  printf("perimeter of triangle is=%f",area);
  return 0;
    Test Case 1

Input (stdin)
2.0 3.0 4.0



Expected Output
perimeter of triangle is=2.904737
Test Case 2

Input (stdin)
3.4 5.6 7.9



Expected Output
perimeter of triangle is=8.178576


1 comment:

  1. ANY DOUBTS PLEASE COMMENT.WE WILL REPLY YOU AS SOON AS POSSIBLE.

    ReplyDelete