samedi 29 novembre 2014

Why do we have to tell printf() the type of data in "C" language?


Let's consider this "C" code:



#include< stdio.h >


main()

{

int x=5;

printf("x is ");

printf("%d",5);

}



In this, when we wrote "int x=5;" we told the computer that "x" is an integer. The computer must remember that "x" is an integer, but when we output the value of "x" in "printf()" we have to again tell the computer that x is an integer, why?


Why the computer forgets that x was an integer.


Thank you.





Aucun commentaire:

Enregistrer un commentaire