You are on page 1of 1

#include <stdio.

h>

int main(){
float b,h;
float area;
char choice;
float side;

printf("\nEnter Your Preferred Area Computation");


printf("\nS - Calculate The Area of Square");
printf("\nT - Calculate The Area of Triangle");
printf("\n\nChoice: ");
scanf("%c",&choice);

if(choice == 'S')
{
printf("S - Calculate The Area of Square");

printf("\nEnter the side: ");


scanf("%f", &side);
area=side * side;
printf("\n\nArea of a Square= %.2f ", area);
}
else if(choice == 'T'){

printf("\nS - Calculate The Area of Triangle");


printf("\nEnter Base of the Triangle: ");
scanf("%f",&b);
printf("\nEnter Height of the Triangle: ");
scanf("%f",&h);
area = (b*h)/2;

printf("\nArea of the Triangle = %.2f",area);


}else{
printf("\nPlease Enter a Valid Choice S or T only!");

return 0;
}

You might also like