Sunday, May 10, 2009

Can someone explain to me in the simplest form. what is "printf" in C++?

outputs a string on console

Can someone explain to me in the simplest form. what is "printf" in C++?
printf is the command to display text.


for example you want to display "hello", the code is...





printf("hello");
Reply:when you want to display text in screen
Reply:Actually printf is NOT c++, it is c.





As others mentioned it is the command to print a string of data to the standard console (i.e. your monitor). The data can be formatted using special characters delmited by a '%' followed by a specification that allows you to substitute for basic data types (floats, ints, exponents, etc.).





If you are programming in C++ you should be using 'cout' and iostream.
Reply:It is used to format variables for easy reading. For example, you might say:





int iterations = 123;


float seconds = 2.55343;


printf("We looped for %d iterations in %.2f seconds\n", iterations, seconds);





You might get output like





We looped for 123 iterations in 2.55 seconds





That's much easier than trying to do it yourself. In C++ you also have the option of "%26gt;%26gt;" and "%26lt;%26lt;" style instead of printf. They both do much the same thing.
Reply:printf mean you are declaring the action or words on the dos screen in an examp is


#include %26lt;stdio.h%26gt;





int main()


{


printf("hello world\n");


return 0;


}





this is also consiterd a varry small but the warry well known program.by D.R.
Reply:It is used to display text.


No comments:

Post a Comment