#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
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 |
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 |
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 |
What is string function c?
Why the use of alloca() is discouraged?
what is ANSI and ISO
Is there a way to compare two structure variables?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
How do you prevent buffer overflows in C?
Why is c not oop?
proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?
What is the advantage of an array over individual variables?
What do you mean by invalid pointer arithmetic?
why ordinary variable store the later value not the initial
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database
2 Answers TCS, Unisys, Webyog,