C
What is the return value from printf() function?
printf function always returns the number of characters printed. Let us understand this with an example:
main()
{
int a=10;
printf("%d",printf("%d %d %d", a,a,a));
}
In this above program the inner printf is first called which prints value of a, three times with space between each value, 10 10 10. Total 5 characters get printed (3 value of 10 and 2 spaces).
As explained earlier the inner printf after printing the values, returns the number of characters printed, 5 which is printed by the outer printf.
The output of the above program is
10 10 10 5
A function always returns a value and printf function returns the number of characters successfully printed.

|
the output is not 10 10 10 5 but i m getting 10 10 108 |

| probably it is taking the value 10 as two characters.then the output ll be 10 10 10 8 |

|
i used "t" with every %d in the inner printf, n i got the output..... 10 10 10 9 dis may b bcoz of the spaces as if we take 1 n 0 as different characters,n count the spaces as well,the total comes out to b 9 1.......1 0.......2 .......3 1.......4 0.......5 .......6 1.......7 0.......8 .......9 |

| when a was taken as 3 he output is correct,ie.,5. So, you guessed right.... |

|
The inner printf will return 8, as it has printed 8 character thrice has it printed a (2*8), as a is two characters wide.and it has printed two spaces as well(between %d %d %d) so total is 8 characters.So the answer comes to be 10 10 108. as first the inner printf executes than the outer one. |
|
printf() returns that how many values it was read.eg:printf() also return the value that let see with eg. #include #include void main() { int l,a=10,b=20,c=30; clrscr(); l=printf("%d%d",a,b); printf("first printf()=%dn",l); l=printf("%d%d%d",a,b,c); printf("second printf()=%dn",l); } output will be: first printf()=2 second printf()=3 explanation: in first printf() it reads two values so that output shown 2,as like second printf() shown output value 3 |
|
printf is used to get the values which are we insert in the prog or runtime the syntax of the printf printf(" |
|
It counts how many unit is printed like if you are going to print 10 10 10 then printf count as 12345678=total 8 and its true.... |

|
i m getting the output 1010106 how |