/*Problem 2*/
#include<stdio.h>
#include<math.h>
int main()
{
float base,side,perimeter,median,s,area,a[100],b[100],temp=0;
int i;
for(i=1;i<=3;i++)
{
printf("Enter the value of base and any other side:");
scanf("%f%f",&base,&side);
perimeter=base+2*side;
median=sqrt(side*side-(base*base/4));
area=0.5*base*median;
a[i]=area;
b[i]=perimeter;
printf("Perimeter of the triangle=%f",perimeter);
printf("\nMedian of the triangle=%f",median);
printf("\nArea of the triangle=%f\n",area);
}
/*Sorting for Maximum*/
for(i=1;i<=2;i++)
{
if(a[i]>a[i+1])
{
temp=a[i];
a[i+1]=temp;
}
else
{
temp=a[i+1];
}
}
printf("\nMaximum Area of the triangles=%f\n",temp);
/*Sorting for Minimum*/
for(i=1;i<=2;i++)
{
if(b[i]>b[i+1])
{
temp=b[i+1];
}
else
{
temp=b[i];
b[i+1]=temp;
}
}
printf("\nMinimum Perimeter of the triangles=%f\n",temp);
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
float base,side,perimeter,median,s,area,a[100],b[100],temp=0;
int i;
for(i=1;i<=3;i++)
{
printf("Enter the value of base and any other side:");
scanf("%f%f",&base,&side);
perimeter=base+2*side;
median=sqrt(side*side-(base*base/4));
area=0.5*base*median;
a[i]=area;
b[i]=perimeter;
printf("Perimeter of the triangle=%f",perimeter);
printf("\nMedian of the triangle=%f",median);
printf("\nArea of the triangle=%f\n",area);
}
/*Sorting for Maximum*/
for(i=1;i<=2;i++)
{
if(a[i]>a[i+1])
{
temp=a[i];
a[i+1]=temp;
}
else
{
temp=a[i+1];
}
}
printf("\nMaximum Area of the triangles=%f\n",temp);
/*Sorting for Minimum*/
for(i=1;i<=2;i++)
{
if(b[i]>b[i+1])
{
temp=b[i+1];
}
else
{
temp=b[i];
b[i+1]=temp;
}
}
printf("\nMinimum Perimeter of the triangles=%f\n",temp);
return(0);
}
Comments
Post a Comment