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



write a program segment that will ask the user if he wants to computer the perimeter of the area o..

Answer / 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

More JavaScript Code Interview Questions

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

0 Answers   HCL,


code to detect availability of cookies

0 Answers  


how to prevent an Event from performing its default behavior

0 Answers   CAE,


code to Hide and Show form controls

0 Answers  


code to calculate the number of days between two dates

2 Answers  






write a code to generate pseudorandom numbes

0 Answers   ABC,


advance the focus to next consecutive fields when Enter Key is pressed

0 Answers   TCS,


Reading which Character Key was pressed

1 Answers  


create a slide show

1 Answers   Genpact,


how to pass data between pages using Frames

0 Answers  


maximizing the main window

0 Answers  


determine which Element received an Event

0 Answers  


Categories
  • PHP Code Interview Questions PHP Code (33)
  • JSP Code Interview Questions JSP Code (6)
  • ASP Code Interview Questions ASP Code (5)
  • CGI Perl Code Interview Questions CGI Perl Code (3)
  • JavaScript Code Interview Questions JavaScript Code (63)
  • VB Script Code Interview Questions VB Script Code (20)
  • Shell Script Code Interview Questions Shell Script Code (31)
  • Python Code Interview Questions Python Code (34)
  • WinRunner Code Interview Questions WinRunner Code (1)
  • HTML DHTML XHTML Code Interview Questions HTML DHTML XHTML Code (13)
  • XML Interview Questions XML (43)
  • Scripts_Markup Code AllOther Interview Questions Scripts_Markup Code AllOther (5)