#include<iostream>
using namespace std;
int main()
{
int k=35;
printf("%d %d %d %d ",k==35,k=50,k,k>40);
return 0;
}
why the output of these problem is
0 50 35 0
problem with c code
Moderator: Board moderators
-
- New poster
- Posts: 13
- Joined: Sat Oct 07, 2006 6:42 pm
- Contact:
problem with c code
hi i have an problem with my c code
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
The order in which arguments of a function call are evaluated is undetermined (the comma as separator in a function call is not the same as the comma as sequencing operator), so in your case the evaluation order might be backwards (which would be consistent with the output, but don't rely on it).
PS. Your code is C++, not C.
PS. Your code is C++, not C.
C standard doesn't specify order in which function's arguments are evaluated, so it can depend on your compiler, compile flags, phase of moon, etc...
More on order of evaluation in C here
In your case, it seems that the compiler evaluated arguments from right to left.
More on order of evaluation in C here
In your case, it seems that the compiler evaluated arguments from right to left.
This can't be C. It's C++.#include<iostream>
using namespace std;
-
- New poster
- Posts: 13
- Joined: Sat Oct 07, 2006 6:42 pm
- Contact:
-
- New poster
- Posts: 13
- Joined: Sat Oct 07, 2006 6:42 pm
- Contact:
Chapter 2, section 2.12, in this book.can u give some another link.