dimanche 30 novembre 2014

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


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 is that?


Why does the computer forget that x was an integer?





Aucun commentaire:

Enregistrer un commentaire