?
Find the output of the following program.
Find the output of the following program.
#include<stdio.h>
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
printf("%d", y);
else
printf("%d", y);
}
#include<stdio.h>
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
printf("%d", y);
else
printf("%d", y);
}
Answer & Solution
Correct Answer:
Option
C
Here if Statement is true and if statement executes left to right. Since its AND operator so all the condition should be check until it finds any false statement.
Initially y = 10
In 1st condition: y++>9 which is true and y become 11 in next use.
In 2nd condition: y++!=10 which is also true and y become 12 in next use
In 3rd condition: y++>11 which is also true and y become 13 in next use
After that printf statement will execute and print y = 13
Join the Discussion
Login to post a comment or share your explanation.
LoginCLS
W$="PATTERN"
FOR I=1 TO 7 STEP 1
PRINT LEFT$(W$,I)
NEXT I;
END
#include
main()
{
float a,s,sq;
printf ("/n enter the number");
scanf ("%f", &a);
s=a8a;
sq=srrt(a);
printf ('/n square= %f," s);
printf ("/n square root =%f," sq);
}
What is program output
#include
void main 0 {
int i = -1, j = -1, k = 0, I = 2, m;
m = i++ &&j++ &&k++ ll 1++;
printf (" Vo dLo d%o dvo dLo d",i j,k,l,m) ;
l
Input "Enter any 3 numbers ";N
IF SGN (N)=1. THEN
PRINT N; "is the odd number"
ELSE
PRINT N; "is null or zero number"
ELSE IF
END