write a program segment that will ask the user if he wants
to computer the perimeter of the area of the triangle. if
the perimeter is wanted, ask the measure of the three sides
and compute for the perimeter. if the area is wanted, ask
for the measures of the base and height and compute for the
area. display the computed value

Answer Posted / shayne delos santos

#include<stdio.h>
#include<conio.h>


int choice,p,a,b,c,area,base, height;


int main()
{
p("This program will get the perimeter and are of Triangle\n");
p("Choices\n");
p("1.] Perimeter\n");
p("2.] Area\n");
p("Enter Choice [1 or 2]: ");
s("%d",&choice);


if (choice == 1)
{
p("Enter Side A: ");
s("%d",&a);
p("Enter Side B: ");
s("%d",&b);
p("Enter Side C: ");
s("%d",&c);
p = a + b + c;
p("The perimeter of the area of a triangle is %d",p);
}


if (choice == 2)
{
p("Enter Base: ");
s("%d",&base);
p("Enter Height: ");
s("%d",&height);
area = (base * height)/2;
p("The area of a triangle is %d",area);
}
getch();
return 0;
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

code to create a new window

1752


how to create a Custom Scrollbar

2044


how to get the User's Time of Day

1662


program to show a progress bar

2119


create Drop-Down Navigation Menus

1698






how to pass data between pages using Cookies

1841


program to bring a window to the front

1558


Create a ViewState Property?

2279


Create a Menu that can be activated while clicking on Right Mouse button

1700


determine which Element received an Event

1897


How to encode and decode URL strings?

1784


code to detect versions of different browsers like internet explorer, netscape, mozilla, opera etc

1732


code to keep a page Out of the browser history

1649


code to images to rollover

1853


Reading which Non-Character Key was pressed

1681