main()
{
if( ? )
{
printf("welcome");
}
else
{
printf("to ieg");
}
}
-----------------------------------------------------------------------
Output should be
welcome to ieg


what should come in place of ' ? '

any conditional statement that is either true or false. for example if you were asked to enter either 'Y' or 'N' (Yes or No) then the statement might read

if( answer == 'Y')
{
   // true statement
}
else
{
   // false statement
}

any conditional statement that is either true or false. for example if you were asked to enter either 'Y' or 'N' (Yes or No) then the statement might read

if( answer == 'Y')
{
   // true statement
}
else
{
   // false statement
}

Thisnk it's a trick question. May be you didn't read it fully..

@mohiuddin.shaik
It is allowed to write/change anything other than ? e.g. can I use a goto inside the if block? :)

you are right -- I didn't read the expected outcome, which is impossible. There is no solution that will give that outcome.

What abt GOTO LABEL?

if ( true )
{
     cout << "Hi" << endl ;
     goto ELSE_PART ;
}
else
{
ELSE_PART:
     cout << " There" << endl ;
}

of course that's cheating but then teh question is not fair.. :)

Seems simple enough

int main()
{
    if (!printf("welcome ")) {
        printf("welcome");
    } else {
        printf("to ieg");
    }
    return 0;
}

Seems simple enough

int main()
{
    if (!printf("welcome ")) {
        printf("welcome");
    } else {
        printf("to ieg");
    }
    return 0;
}

Wow... Salem! You never fail to impress me... (I'd give you more rep if the system would let me ;))

This article has been dead for over six months. Start a new discussion instead.