C Programming :: String - Discussion
Home > C Programming > String > MCQs Questions Discussion
6 / 26
What is the output of the following problem ?
#include<stdio.h>
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok Done \n");
else
printf("Forget it\n");
}
#include<stdio.h>
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok Done \n");
else
printf("Forget it\n");
}
AForget it
BOk Done
CCompilation Error
DNone of these
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
'printf()' function returns the number of characters printed. Here, it prints the Zero or the null character, hence it returns 1. So, the 'if' part now becomes something like 'if(1)', which is 'true' as 1 is not equal to 0. Therefore, the 'if' block gets executed and as a result "Ok Done" is the output.
Read Full Answer
Report Error
Please Login First Click Here