Day#53 'C' Coding Challenge

Day#53 'C' Coding Challenge

What is the output of the simple code below?

#include <stdio.h> void main() { printf("%d\n%d\n",1,2,3,4,5); }

----------------------------------------------------------------

A simple code using the printf() function is written.
While executing the code, compiler looks at the format specifier to determine the type of variables to be printed.
In the above printf statement, printf("%d\n%d\n",1,2,3,4,5), there are two format specifiers, %d, %d, however in the arguments section there are 5 arguments. As the format specifiers is what compiler looks at, the output shall be 1,2.

----------------------------------------------------------------

The printf() function format is,
printf(char *format, arg1, arg2, arg3,...)

char *format is the format specifier
format specifier starts with % and ends with required conversion type character
arg1, arg2 are the arguments

Post a Comment

0 Comments