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 num[] = {1,2,3,4,5,6};
    num[1] == [1]num ? cout << "Success" : cout << "Error";
    return 0;
}

Error :

expected primary-expression before '[' token.

Description :

In line 6, the syntax for representing an array is wrong,i.e '[1]num'. Instead,it should be like 'num[1]'.

No comments:

Post a Comment