Memory consumption by printf( )
c, c++
Solution
Does displaying a simple statement in C(or C++) occupies some memory?
Yes, of course. The string constant has to be stored somewhere, usually in a read-only segment of memory. The `printf` and `cout` facilities also take up space.
will it make a difference if i attach some value of a variable to be displayed in the same statement?
Yes. The parameters have to be stored somewhere, usually on the stack, so the memory used by the parameters will be returned after the `printf` or `cout` call ends. Also the call itself probably generates a few more instructions in the calling routine to push the parameters on the stack.
Problem
Does displaying a simple statement in C (or C++) occupy some memory? For example, ``` //in C printf("\nHello World"); //in C++ cout<<"Hello World" ; ``` and, will it make a difference if I attach some value of a variable to be displayed in the same statement? For example, ``` printf("Value is %d" , var) ; ```