5.7k views
0 votes
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 }

1 Answer

6 votes

Answer:

Line 8 gives a compiller Error

Step-by-step explanation:

In line 8, the statement: if (number >= 0 && <= 100) will give a compiller error because when using the logical and (&&) It is required to state the same variable at both sides of the operator. The correct statement would be

if (number >= 0 && number <= 100). The complete corrected code is given below and it will display the output "passed"

#include <iostream>

using namespace std;

int main()

{

int number = 5;

if (number >= 0 && number <= 100)

cout << "passed.\\";

else

cout << "failed.\\";

return 0;

}

User Singaravelan
by
4.9k points