quiz 3

Output of the following?

#include<stdio.h>
int main()
{
   int a,b,c,d,e,f;
   a=1;b=4;c=2;d=3;e=5;f=3;
   printf("%d",1-a+b*c%d/(e-f));
   return 0;
}

Choices:

a) compile error     b) execution stops     c) 0     d). 1     e) -3      f) 2    g)none
For explanation visit "click here for program" link below.



step.1: 1-a+b*c%d/(5-3)     ( brackets have highest priority among all)
step.2: 1-a+b*c%d/2
step.3: 1-a+4*2%d/2          ( *,/,% have same priority and have left to right associativity )
step.4: 1-a+8%3/2
step.5: 1-a+2/2
step.6: 1-a+1
step.7: 1-1+1                     ( +, - have same priority and have left to right associativity)
step.8: 0+1
step.9: 1
Now the expression returns its result. so 1 is printed
 
Don't want to miss updates from us!! follow us or subscribe to us.

3 comments:

pawan weg said...

Your post is awesome and so informative for computer science students.

if you want news related content so pls visit here ->> Scorpio New Modal

Samar Set said...

https://samar-set-news.blogspot.com/

Anushi said...

Thanks for your information blog, this is nice and helpful… Definitely going to share this article with your friends, thanks for sharing this blog article.
Top 10 World Popular Sites