What is the return value from printf() function?

January 16, 2025 No Comments »







Tags : Nested Printf | nesting of Printf | Printf within Printf having Blank Spaces

What is the return value from printf() function?
#include<stdio.h>void main(){    int a=20;    printf("%d",printf("%d %d %d", a,a,a));}

Output :

20 20 208 

Why ?
  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 .
  4. printf("%d",8);
  5. Outer Printf will Print “8″

Leave A Response