Free clock The C Programming Language: printf() Function

Wednesday, January 7, 2009

printf() Function

int printf(const char *format,...) this is the fuction declaration for printf() it takes constant characters or string as input. The preceding ... variable arguments i.e. it can have many arguments as data for printf. For example, we have to display an integer we use %d , for character we use %c, for string we use %s and for a floating point number we use %f.

printf("int=%d, float=%f, char=%c, string=%s", 4, 5.5, 'k', "hello");

Output:

int=4, float=5.5, char=k, string=hello

All characters followed by % according to their special meaning.

Every instruction in C is followed by a ';' called the end of statement. At this point all the instruction ends, as C is a case sensitive language and there is no meaning of white spaces or newlines unless they are included within " ", where they have the meaning of a character.

Next we'll have a close look at the data types.

No comments:

Post a Comment