What is the return value from printf() function?

What is the return value from printf() function?

  1. Printf Statement is used to Print Something on Console (On Screen).
  2. Printf is Predefined function is C Programming Language.
  3. Printf Statement always returns Integer Value.

Live Example : Return Value of Printf

#include<stdio.h>
void main()
{
   int a=20;
   printf("%d",printf("%d%d%d", a,a,a));
}

Output :

20 20 208

Why we get such Output ?

  1. Rules : Always Innermost Printf will be executed First .
  2. Printf function returns the number of characters printed.
  3. In the Above Example of Nested Printf , Inner Printf Prints [20 20 20] , here number of Characters Printed On Screen = 8 (including two Blank Spaces)
printf("%d",8);
  1. Outer Printf will Print “8″

Yet Another Sample Example :

#include<stdio.h>
void main()
{
   printf("%d",printf("Hello"));
}

Output :

Hello5