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


what should come in place of ' ? '

Recommended Answers

All 7 Replies

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.

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.. :)

You have just gone out to show one of the horrors of using the GOTO statement in C/C++... :D

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 ;))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.