C Programming :: Declarations and Initializations - Discussion
1 / 54
#include <stdio.h>
int main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
return 0;
}
#include <stdio.h>
int main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
return 0;
}
Astatement 1
Bstatement 2
CCompilation Error
DNo Output
Show Explanation
Asked In ::
Answer: option B
Explanation :
if statement executes only when condition is true
Read Full Answer
Report Error
Please Login First Click Here
Answer: option B
Explanation :
if statement executes only when condition is true
Read Full Answer
Report Error
Please Login First Click Here
Initially the value assigned to i is equal to 4. In the if condition it is checked that if i value is equal to 0 then print Statement 1. But the i value is 4 so condition 1 is not accepted and hence else condition is accepted because if else condition has to run one particular rather if or else.
Read Full Answer
Report Error
Please Login First Click Here
in the if statement i should be compared with 0 not assigned
Read Full Answer
Report Error
Please Login First Click Here
header file not included
Read Full Answer
Report Error
Please Login First Click Here
Explanation: 1. Header file is missing.
2. In line 5, we are comparing value of i with 0, so while comparing values we always use a relational operator(==) instead of assignment operator(=).
Read Full Answer
Report Error
Please Login First Click Here
HEADER FILE WAS MISSING AND COMPILATION ERROR
Read Full Answer
Report Error
Please Login First Click Here
HEADER FILE WAS MISSING AND COMPILATION ERROR
Read Full Answer
Report Error
Please Login First Click Here
HEADER FILE WAS MISSING AND COMPILATION ERROR
Read Full Answer
Report Error
Please Login First Click Here