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
 Enter value

Click to edit the document details