ASSIGNMENT 2
QUES 1:
What is the output of following program?
int a = 5 ;
int b = 8 ;
int c = -10 ;
if(a = a > b < c)
{
printf("If : %d %d %d\n", a, b , c) ;
if(b = a -= b += c)
{
printf("IfIf : %d %d %d\n", a, b , c) ;
}
else
{
printf("IfElse : %d %d %d\n", a, b , c) ;
}
}
else
{
printf("Else : %d %d %d\n", a, b , c) ;
if(b = b += c -= a)
{
printf("ElseIF : %d %d %d\n", a, b , c) ;
}
else
{
printf("ElseElse : %d %d %d\n", a, b , c) ;
}
}
QUES 2:
What is the output of following program?
int a = 10 ;
if(a ^= printf("CodingIsFun\n") >> printf("Hi\n"))
{
printf("In If %d\n" , a) ;
}
else
{
printf("In Else %d\n", a) ;
}
QUES 3:
What is the output of following program?
int a = 20 ;
int b = 20 ;
if(b += a++ || printf("hello\n"))
{
printf("Inside If : a : %d b : %d\n" , a , b ) ;
if(a -= b /= 5 || printf("hii\n") && printf("bye\n"))
{
printf("Inside If If : a : %d b : %d\n" , a , b) ;
}
else
{
printf("Inside If Else : a : %d b : %d\n" , a , b) ;
}
}
QUES 4:
What will be the output of following program?
int y = 8 ;
for (int i = y+= 2 ; printf("CD : %d\n", i) && i <= 12 ; printf("RE : %d\n" , i++))
{
printf("BD : %d\n" , i) ;
}
QUES 5:
What is the output of following program?
for(int i = 1 , j = 10 ; i++ , j-- , i < j ; i++, j--)
{
printf("%d %d\n" , i , j) ;
}
QUES 6:
What is the output of following program?
int count = 1 ;
do
{
if(count <= 2)
continue ;
printf("%d : in loop\n", count) ;
count++ ;
}
while (printf("%d : in condition\n", count) , count++ <= 5);