This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
i now study for my test and i have this q
#define MAX2(A,B) (((A)>(B))?(A):(B))
the q start here
#define MAX3(A,B,C) (MAX2(MAX2(A,B),C))
int f();
int g();
int h();
and ends here the (rest of the code i did
the q prety much ask how many times does any function runs)
the answer is f:4 g:2 and h:1
why g is 2?
i get f4 i get h1 why g 2?
and here is the order its happeing:
f ,g, f, h,f g,f
why g happens in the end again?
int main()
{
int i = MAX3(f(), g(), h());
}
int f() {
int static Foccur = 0;
Foccur ;
printf("f runed %d\n", Foccur);
return 5;
}
int g() {
int static goccur = 0;
goccur ;
printf("g runed %d\n", goccur);
return 4;
}
int h() {
int static hoccur = 0;
hoccur ;
printf("h runed %d\n", hoccur);
return 1;
}
Subreddit
Post Details
- Posted
- 4 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/AskProgramm...