Ans:
Compare to relational operators the shift operators have the higher precedence.
Ex - 1: What is the output?
main()
{
int y;
scanf("%d",&y); // input given is 2000
if( (y%4==0 && y%100 != 0) || y%100 == 0 )
printf("%d is a leap year");
else
printf("%d is not a leap year");
}
Ans:
2000 is a leap year
Explanation:
An ordinary program to check if leap year or not.
Ex - 2: What is the output?
#include
main()
{
const int i=4;
float j;
j = ++i;
printf("%d %f", i,++j);
}
Ans:
Compiler error
Explanation:
i is a constant. you cannot change the value of constant
Ex - 3: What is the output?
main()
{
int i=5,j=6,z;
printf("%d",i+++j);
}
Ans:
11
Explanation:
the expression i+++j is treated as (i++ + j)