Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Monday, January 24, 2011

Identify the error in the following code snippet.

Code Snippet :

#include<iostream>
using namespace std;
int main()
{
    int i = 0;
    i = i + 1;
    cout << i << " ";
    /*comment\*// i = i + 1;
    cout << i;
    return 0;
}

Error :

expected primary-expression before '/' token.

Description :

In line 8, the multi-line comment is ended by '*/', but the syntax for single line comment '//' is wrong. So the compiler treats it as division operator '/'.

No comments:

Post a Comment