What will be the output of the given program?
#include<stdio.h>
void main()
{
int a=11,b=5;
if(a=5) b++;
printf("%d %d", ++a, b++);
}
#include<stdio.h>
void main()
{
int a=11,b=5;
if(a=5) b++;
printf("%d %d", ++a, b++);
}
A. 12 7
B. 5 6
C. 6 6
D. 6 7
E. 11 6
Answer: Option C
Solution(By Examveda Team)
Here if condition evaluates to true as a non-zero value i.e 5 is assigned to a.
So the value of a = 5 and after increment value of b = 6.
In printf statement due to pre-increment of a value of a printed will be 6 and due to post-increment of b value of b printed will be 6 and not 7.
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
Join The Discussion