What is wrong with the following program? #include //Line 1 namespace aaa //Line 2 { const int X = 0; //Line 3 double y; //Line 4 } using namespace std; //Line 5 int main() //Line 6 { y = 34.50; //Line 7 cout << "X = " << X << ", y = " << y << endl; //Line 8 return 0; //Line 9 }

Respuesta :

Answer:

#include //Line 1

namespace aaa //Line 2

{ const int X = 0; //Line 3

double y; //Line 4

}

using namespace std; //Line 5

int main() //Line 6

{ y = 34.50; //Line 7

cout << "X = " << X << ", y = " << y << endl; //Line 8

return 0; //Line 9

}

In Line 1, No header file is present,so it will print output as cout and endl is not defined.

we should include <iostream> header file in line 1  

Lines 7 and 8 are incorrect.

X and y variables in aaa namespace are stated. So we can't use it any other namespace(std), but here y is initialized to 34.50 and x is printed in other namespace rather than stated.

Otras preguntas

ACCESS MORE