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.\n"; 10 else 11 cout << "failed.\n"; 12 return 0; 13 }

Respuesta :

ijeggs

Answer:

Line 8 gives a compiller Error

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.\n";

   else

       cout << "failed.\n";

   return 0;

}