60 507
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #26723 in C++ for santosh

Question #26723
write a program in c++ to find out the area of a right angle triangle
Expert's answer
#include <iostream>

int main()
{
//show message and enter first leg of triangle
std::cout <<"Enter first leg of right triangle\n";
float a=0;
std::cin >>a;

//show message and enter second leg of triangle
std::cout <<"Enter second leg of right triangle\n";
float b=0;
std::cin >>b;

float area=0;
//if input correct then calculate an area else show error message
if( ( a>0 ) && (b>0) )
{
area=a*b*0.5;
std::cout <<"Area=" <<area <<"\n";
}
else
{
std::cout <<"Input error!\n";
}


return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions