Computer Programming CS F111. Vishal Gupta Department of Computer Science and Information Systems Birla Institute of Technology and Science Pilani Campus, Pilani . Agenda :. Expression Evaluation: Precedence & Associativity. Precedence and Associativity ?.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Department of Computer Science and Information Systems
Birla Institute of Technology and Science
Pilani Campus, Pilani
Expression Evaluation: Precedence & Associativity
1) z = 2*3/4+4/4+8-2+5/7
z = ??
2) y = 4/5*6+2/7+4
y = ??
3) Let inta,b;
x = a/b*(c+d)/a-b+c/d
What is the output of the following piece of code ??
int main (void)
int a, b=21, c=7;
a = ++c – b-- % 5;
printf (“Value of a = %d, b = %d, c = %d”,a, b, c);
Priority can be overruled by parenthesis. With this expression inside parenthesis are evaluated first so
(1+2)*3 gives 9