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 = 5;
    while(i)
    {
        switch(i)
        {
            default:
            case 4:
            case 5:
                break;
            case 1:
                continue;
            case 2:
            case 3:
                break;
        }
        i-;
    }
    return 0;
}

Error :

expected primary-expression before ';' token.

Description :

In line 20, the syntax for unary operator is wrong. It should be 'i--;' instead of 'i-;'.

No comments:

Post a Comment