Welcome Guest | Sign in | Register
Arrays - Discussion Page For Q.10419 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Arrays > Questions and Answers

Q: What will be output when you will execute following C code?
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");
}
A. Compilation error B. Ok here
Forget it
C. Forget it D. Ok here

Answer and Explanation

Answer:Ok here

Explanation:
Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok here" is printed.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.