#include<conio.h>
#include<stdio.h>
void main()
{
int i;
if(1,0,2,3)
{
printf("if");
}
else
{
printf("else");
}
getch();
}
Can any body tell the answer of this question with explanation?

Answers were Sorted based on User's Feedback



#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf(&qu..

Answer / shyamkumar1221

the question might be like this
#include<conio.h>
#include<stdio.h>
void main()
{
int i=1;
intj=0,k=2,l=3;
if(i,j,k,l)
{
printf("if");
}
else
{
printf("else");
}
getch();
}
the output would be if
since in the if ()we are using comma operator.the precedence
is left to right...since in the if the we get output as 3
which is non zero.the if statement is true and if statement
will be printed

Is This Answer Correct ?    11 Yes 1 No

#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf(&qu..

Answer / guest

yhaa... it will print if....... okay...


why u know.... because in if condition u r not checking any
conditions... thatis why,,,,,

Is This Answer Correct ?    0 Yes 1 No

#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf(&qu..

Answer / prateek songara

By default "i" will posses the value 2 bcoz of "int" and when it moves to "if" it will check all the values matches with its value (1,0,2,3) and if he gets the match then it will print the "if" ..else it will print the "else"..........hope you got the answer now.

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C Interview Questions

What is the easiest sorting method to use?

0 Answers  


Can one function call another?

0 Answers  


Tell me the use of bit field in c language?

0 Answers  


What's the difference between a linked list and an array?

14 Answers  


Write a program to produce the following output in c language? 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

2 Answers  






What is a class?

3 Answers  


Write a c program using for loop in switch case?

1 Answers   Infosys,


Write a program that his output 1 12 123

0 Answers  


What is the result main() { char c=-64; int i=-32 unsigned int u =-16; if(c>i){ printf("pass1,"); if(c<u) printf("pass2"); else printf("Fail2");} else printf("Fail1); if(i<u) printf("pass2"); else printf("Fail2") } a)Pass1,Pass2 b)Pass1,Fail2 c)Fail1,Pass2 d)Fail1,Fail2 e)none

9 Answers   IBM,


What is the purpose of void pointer?

0 Answers  


m=++i&&++j(||)k++ printf("%d"i,j,k,m)

1 Answers   ABC,


What is the role of && operator in a program code?

0 Answers  


Categories