hw12_engr13200_s11

# hw12_engr13200_s11 - ENGR 13200 Ideas to Innovations Part...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Spring 2011 3. Review – Conditional Statements This is to be completed individually. This problem is added to your homework grade. The area of a triangle can be calculated from the lengths of the three sides using Heron's formula: ( 29( 29( 29 A s s a s b s c = - - - where 2 a b c s + + = Identify THREE errors in the code below using the table after the code. Clearly indicate the line number of the error, describe the error and how it could be fixed. Each error counts as one, even if there are multiple errors on the same line. Line 1 function [heron_area] = TriArea(side_a,side_b,side_c) 2 % This function calculates the area of a triangle given the lengths of the % three sides using Heron's equation. 3 % 4 % INPUT ARGUMENTS: side_a = the length of side a of the triangle 5 % side_b = the length of side b of the triangle 6 % side_c = the length of side c of the triangle 7 % 8 % OUTPUT ARGUMENTS: heron_area = the area of the triangle 9 10 % ---- Calculation Section ---- 11 if side_a && side_b && side_c <= 0 12 fprintf('One of the sides is negative or zero') 13 elseif 14 s = (side_a+side_b+side_c)/2; % the half perimeter of the triangle 15 heron_A = sqrt(s*(s – side_a)*(s – side_b)*(s – side-c)); 16 end 17 18 Line number What is the error? How could it be fixed?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

hw12_engr13200_s11 - ENGR 13200 Ideas to Innovations Part...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online