Printf MCQ 20 : Return printf as Parameter
Printf Multiple Choice Questions : Return Parameter as Printf
Question : Guess the output of Program
#include<stdio.h> #include<conio.h> int func1() { return(printf("Hello")); } void main() { int i; i = func1(); printf("%d",i); }
Options :
- Compile Error
- Run Time Error
- Hello
- Hello5
[toggle title="Output"]Hello5[/toggle]
Switch to Printf MCQ Home : Click Here
How and Why ?
- Printf Returns Length of String Literal i.e String Inside Quotes.
Example : printf("Hi"); returns 2
- In Above Example , Function First Prints “Hello” and then Returns the Length of “Hello”