207k views
1 vote
Which line in the following program will cause a compiler error?

1. #include
2. using namespace std;
3.
4. int main()
5. {
6. int number = 5;
7.
8. if (number >= 0 && <= 100)
9. cout << "passed.\\";
10. else
11 cout << "failed.\\";
12 return 0;
13 }

A) 8 B) 6 C) 10 D) 9

User Ayon
by
8.2k points

1 Answer

0 votes

Answer:

The answer is "Option A".

Explanation:

  • In the given C++ Language program on line 8 compile-time error will occur, because in the code the conditional statement is used. In if block, we check two conditions together, which is the number variable value is greater than equal to 0 and check less than equal to 100.
  • In this condition statement, a AND operator is used that execute when both condition is true, but in the last condition, we do not define a variable name that, checks value. That's why the program will give an error on line 8.
User Colin T Bowers
by
8.3k points