Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following statements are correct about the below program?

#include <stdio.h>
int main()
{
    int i = 10, j = 15;
    if(i % 2 = j % 3)
        printf("IndiaBIX\n");
    return 0;
}

 

  • A.Error: Expression syntax
  • B.Error: Lvalue required
  • C.Error: Rvalue required
  • D.The Code runs successfully

Answer: B

Correct answer: Error: Lvalue required

= is assignment, not comparison, and its left operand must be an object that can be assigned to. i % 2 is a computed value, so the compiler reports that an lvalue is required. The author meant ==.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.