Hello friends today I am sharing new concept of printf within printf.
Rule :Inner printf returns Length of string printed on screen to the outer printf
Output :
Know How ?
In this concept one printf demonstrating an other printf.
Printf inside printf in C : Example #include<stdio.h>
#include<conio.h>
void main()
{
int num=1342;
clrscr();
printf("%d",printf("%d",printf("%d",num)));
getch();
}
134241
Know How ?
- Firstly Inner printf is executed which results in printing 1324
- This Printf Returns total number of Digits i.e 4 and second inner printf will looks like
-
printf("%d",printf("%d",4)); - It prints 4 and Returns the total number of digits i.e 1 (4 is single digit number )
-
printf("%d",1); - It prints simply 1 and output will looks like 132441