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

how to delay a function call ?

1 Answers  


determine which key was pressed and its type

1 Answers  


<html> <head> <title>BASIC CALCULATOR</title> </head> <script language= "javascript"> function= setValue(){ var a_term1 </script> <body> <center> <table> <tr> <td><input type="text" id="text box1" style="width:50px"> </td> <td><input type="text" id="text box2" style="width:40px"> </td> <td><input type="text" id="text box3" style="width:50px"> </td> </tr> </table> <table> <tr> <td><input type="text" id="text box4" ></td> </tr> </table> <table> <tr> <td><input type= "button" value= "7" onClick="" ></td> <td><input type= "button" value= "8" onClick="" ></td> <td><input type= "button" value= "9" onClick="" ></td> <td><input type= "button" value= "/" onClick="" ></td> </tr> <td><input type= "button" value= "4" onClick="" ></td> <td><input type= "button" value= "5" onClick="" ></td> <td><input type= "button" value= "6" onClick="" ></td> <td><input type= "button" value= "*" onClick="" ></td> </tr> <td><input type= "button" value= "1" onClick="" ></td> <td><input type= "button" value= "2" onClick="" ></td> <td><input type= "button" value= "3" onClick="" ></td> <td><input type= "button" value= "-" onClick="" ></td> </tr> <td><input type= "button" value= "0" onClick="" ></td> <td><input type= "button" value= "C" onClick="" ></td> <td><input type= "button" value= "=" onClick="" ></td> <td><input type= "button" value= "+" OnClick="" ></td> </table> </center> </body> <hr/> </html> how do i make the calculator work now

1 Answers  


How to Add Message and Confirmation Boxes Using JavaScript?

1 Answers  


code to create a new window

0 Answers  






how to create an anonymous function

0 Answers  


how to transform XML Data into HTML

0 Answers  


write a function to validate a given date

1 Answers  


create a slide show

1 Answers   Genpact,


how to copy form data between different pages

0 Answers  


How to encode and decode URL strings?

0 Answers   TCS,


how to determine which Mouse Button was pressed

1 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)