What is the output of the below program?
#include <stdio.h> void main(void) { printf("%d", printf("TalentEve")); }
------------------------------------------------
The above code tests following scenarios:
------------------------------------------------
In the given code, we are trying to print integer value by using format specifier as "%d" but in the variable section the variable is not mentioned. Instead a printf is used.
The compiler treats printf("TalentEve") as another printf function which prints TalentEve with the return type of string length which is 9. So, as we used the format specifier "%d", it prints 9.
So, output is TalentEve9
---------------------------------------
printf function has the following standard format:
printf(const char * format,..........)
The format could be below:
- a standard text which takes form for example printf("embeddeddesignblog");
- use a format specifier which takes form for example printf("%d",n);
0 Comments