This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: clever comes about by considering the product of a and b . Solution: %quiz2.m clear a = input(Enter value for a: ); b = input(Enter value for b: ); if (a*b) > 0 result = a+b; fprintf(\n (%g) + (%g) = %g \n,a,b,result) end if (a*b) < 0 result = ab; fprintf(\n (%g)  (%g) = %g \n,a,b,result) end Or if you did not get the hint could also do if (a > 0 && b > 0)  (a < 0 && b < 0) result = a+b; fprintf(\n (%g) + (%g) = %g \n,a,b,result) end if (a < 0 && b > 0)  (a > 0 && b < 0) result = ab; fprintf(\n (%g)  (%g) = %g \n,a,b,result) end...
View
Full
Document
 Spring '07
 Hayes

Click to edit the document details