PROGRAM LANGUAGE PRIN
PROGRAM LANGUAGE PRIN COP 5555
Popular in Course
Popular in Computer Programming
This 2 page Class Notes was uploaded by Hans Farrell PhD on Friday September 18, 2015. The Class Notes belongs to COP 5555 at University of Florida taught by Staff in Fall. Since its upload, it has received 32 views. For similar materials see /class/206696/cop-5555-university-of-florida in Computer Programming at University of Florida.
Reviews for PROGRAM LANGUAGE PRIN
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 09/18/15
1 No they are not contradictory When there are consecutive identical operators within an expression associativity determines which subexpressions are arguments of which operators It does not determine the order in which those subexpressions are evaluated For example left associativity for subtraction determines that fa gb hc groups as fa gb hc rather than fa gb hc but it does not determine whether f or g is called first 2 Let N represent unary negation es it s needed PostfixbNbb4acsqrt2a PrefixNbsqrtbb4ac 2a 3 Without parentheses would 2 3 4 5 6 evaluate to 2 3 4 5 6 27 or to 2 3 4 5 6 lZl More accurately issues of precedence and associativity do not arise with prefix or postfix notation in which each operator takes a fixed number of operands 4 firstizeroirow l39 for i 039 i lt n ampamp firstizeroirow l39 i firstizeroirow i39 for j 0j ltnj if Alil l firstizeroirow l39 break If C allowed us to use a continue statement to jump to the next iteration of a specific named loop we could write the following firstizeroirow l39 none outer for i 039 i lt n39 i for j 0j ltnj if Ai continue outer not C firstizeroirow i39 break39 l l h n1 while 1 lt h m oor lh2 iftXm exit iftltXm h m else 1 ml 6No The macro must either call a subroutine or execute a loop It must also take the form of an expression in order to return a value C provides no way for an expression to contain a loop Many C implementations however including gcc extend the language to include statement expressions that eliminate this restriction The following macro works with gcc de ne GCDa b While a l b ifa gt 13 a a b 6156 b b a a