473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

printf related...

hi!!!
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;
printf("%d",val+1,"%d",val--);
return(0);
}
Jun 13 '07 #1
4 1473
gpraghuram
1,275 Expert 1GB
Hi,

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

Other members can add to this

Raghuram
Jun 13 '07 #2
And what about the
"%d",val+1 part???..Why theres no contribution?
Jun 13 '07 #3
gpraghuram
1,275 Expert 1GB
HI,
If u see the prototype of printf it is
printf(char*s,...);
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

Raghuram
Jun 13 '07 #4
hi
yah got it!!!..thanks a lot!!
Jun 14 '07 #5

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

Similar topics

18
by: Manohar S | last post by:
It is a problem related to printf, and buffering to the printf statements Look through this program. main() { int pid; int loop,max=3; for(loop = 0; loop <max;loop++) { pid = fork();
5
by: Peter Ammon | last post by:
It's my understanding that the printf() function is declared as int printf(const char * restrict format, ...); in stdio.h. And loosely speaking, if a parameter is declared as restricted, then...
3
by: nandh_dp | last post by:
When the below program is compiled and executed, #include <stdio.h> #define MASK 0xFFFFFFULL main() { unsigned long long a; unsigned long b, c;
19
by: v4vijayakumar | last post by:
why the following statement dumps the core(Segmentation fault)? printf("%s\n", __FILE__);
36
by: Debaser | last post by:
I've recently read in one of my old C books that puts() is a better function call with regard to performance than printf() in the following situation: puts("Some random text"); vs. ...
19
by: RedDevilDan | last post by:
I am working on a Memory Footprint Reduction project. I came across an idea to disable all printf statements so that less memory is required. In addition, when there is no single printf statement,...
6
by: WeiWangJi | last post by:
int i=8; printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,++i,--i,i--,i++,-i--); printf("%d\n", i); why the results is: 8 8 7 8 8 -8 7 How to explain?
7
by: PawelCarqowski | last post by:
Hallo group members, Do You know any conversion specification for this. I imagine: struct timeval time; printf("%T\n", time); regards, Pawel
40
by: somenath | last post by:
Hi All, I have one question regarding the behavior of printf function. In page number of 154 in K&R2 in Table 7-1 it is stated that Characters Argument Type :...
10
by: Rahul | last post by:
Hi Everyone, I had a query reg printf(). I heard that it can't be used in ISR's as it is non-re-enterant. I didn't get as to why printf is non-re-enterant and why non-re-enterant library can't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.