Skip to main content

Printf within Printf

Hello friends today I am sharing new concept of printf within printf.
In this concept one printf demonstrating an other printf.

Rule :Inner printf returns Length of string printed on screen to the outer 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();
}
 
Output :
134241


Know How ?
  1. Firstly Inner printf is executed which results in printing 1324 
  2. This Printf Returns total number of Digits i.e  4 and second inner printf will looks like
  3. printf("%d",printf("%d",4));
  4. It prints 4 and Returns the total number of digits i.e 1 (4 is single digit number )
  5. printf("%d",1);
  6. It prints simply 1 and output will looks like 132441

Popular posts from this blog

Balloon Shooting game in cpp

Balloon Shooting Game is a simple game using c and cpp features. You can easily learn and is easy to run because this game works in TURBOC compiler. The main features are included is  GRAPHICS and DOS commands. Basic commands used in this game : initgraph : initgraph is used to initialising of graphics mode in the program.                   ex. initgraph(&gm,&gd,"akshay"); here gm uses Graphics detect mode and gd points to graphics features to be used in program ans last is a string it may be any string like c://tc/bin etc.. setbkcolor : sets the current background color.    for ex. if you want to set background color to blue, you can call   setbkcolor(BLUE); or setbkcolor(1); getimage : saves a bit image of the specified region into memory. putimage : outputs a bit image onto the screen. settextstyle : sets the current text characteristics.     Declaration : settextstyle(int font, int direction, int charsize); outtextxy : displays a string a

Minesweeper Game in C

Minesweeper Game in C language. This game is like a windows minesweeper game and I am giving you all the code for this game. You can easily understand the code if you are not a beginner. For beginners this code will quite hard to understand. Because in this code it contains mouse pointing function, graphics function, and so many other codes which makes it so hard to play and is a mind game. So play and enjoy it.   Click here for code Click for code

Make your own paint application in c and cpp

Paint application using simple turboc complier. Hello friends now make your own paint application or mini project in your simple c and cpp compiler. click to show the code for paint program