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);
}
A. 11
B. 12
C. 13
D. 14
E. Compilation error
Answer: Option C
Solution(By Examveda Team)
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 = 13Join The Discussion
Comments ( 6 )
Related Questions on Control Structures
Which control structure is used to repeatedly execute a block of code in C?
A. for loop
B. if statement
C. switch case
D. while loop
In C, what is the purpose of the 'break' statement within a loop?
A. Continue to the next iteration
B. Exit the program
C. Terminate the loop and exit it
D. Skip the current iteration
What is the purpose of the 'else' statement in C's 'if-else' control structure?
A. Execute the 'if' block
B. Execute the 'else' block
C. Execute both 'if' and 'else' blocks
D. Skip the 'if' block
Which control structure is used to make a decision between two or more alternatives in C?
A. switch case
B. for loop
C. if statement
D. while loop
WHAT IS THIS PROGRAMS OUTPUT
CLS
W$="PATTERN"
FOR I=1 TO 7 STEP 1
PRINT LEFT$(W$,I)
NEXT I;
END
#include
#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
Cls
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
how?
how