By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

printf related...

P: 10
Please help me out as to what would be the output of the following code and whats the reason for it????
What will be the output of the following program :
int main()
int val=10;
Jun 13 '07 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 1,275

The output will be 10. Because the -- operator has more precedence.

Other members can add to this

Jun 13 '07 #2

P: 10
And what about the
"%d",val+1 part???..Why theres no contribution?
Jun 13 '07 #3

Expert 100+
P: 1,275
If u see the prototype of printf it is
Only the first argument is taken for format specification and following values are taken as corresponding values for format specifiers.

If u specify 3 format specifiers and dosent specify 3 values then the compiler will give an error Example:- printf("%d %d%d",val);

On the other hand, if u specify one format specifier and multiple values then the compiler will discard the remaining values example is what u have given

But since the -- has more preceedence the value changes but it wont get printed

Jun 13 '07 #4

P: 10
yah got it!!!..thanks a lot!!
Jun 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.