- #1
pairofstrings
- 411
- 7
Why is the answer "1"?
Here is a program :
#include<stdio.h>
#include<conio.h>
void main()
{
int i,x=10,y=20,z=5;
clrscr();
i=x<y<z;
printf("%d\n",i);
getch();
}
I am getting the answer as "1". Why? Isn't this suppose to give garbage value if not "0" (zero). Also, please tell me the cases when the answer could be a garbage value or a zero. Please give simple examples. And can you tell me why clrscr(); syntax has to be typed after integer (int) declaration? - Or else it will give you an error.
Thank you very much.
Here is a program :
#include<stdio.h>
#include<conio.h>
void main()
{
int i,x=10,y=20,z=5;
clrscr();
i=x<y<z;
printf("%d\n",i);
getch();
}
I am getting the answer as "1". Why? Isn't this suppose to give garbage value if not "0" (zero). Also, please tell me the cases when the answer could be a garbage value or a zero. Please give simple examples. And can you tell me why clrscr(); syntax has to be typed after integer (int) declaration? - Or else it will give you an error.
Thank you very much.
Last edited: