This is use less question , there is no possiblity that both if and else should
execute if its , then there is no use of if and else.
--- On Mon, 5/1/09, madhansansel <madhansansel@...> wrote:
From: madhansansel <madhansansel@...>
Subject: Re: (PT) a question
To: Programmers-Town@yahoogroups.com
Date: Monday, 5 January, 2009, 12:45 PM
Agreed with Santhosh.
You can ask the interviewer, the need for doing so.
If your CPU executes both the if and else part, then there is no
use of making if and else stmt.
Note: I didn't compile the below sample programs, Please compile and
check it...
Sample 1:
=========
if (!printf("Hi" )) {
;
} else {
printf("I checked only if Condition\n" );
}
Sample 2:
=========
if (1) {
printf("I am in If Part \n");
printf("Please execute a part of else part \n");
goto EXECUTE_ELSE;
} else {
printf("A Stupid Program\n");
EXECUTE_ELSE:
printf("My Compiler Allows me and I executed If and else
Successfully\ n");
}
If Sample 2 works fine, then you can check with setjump and longjump
(just for fun)....
Thanks,
Madhan
--- In Programmers- Town@yahoogroups .com, "Santosh Vernekar"
<santosh.ver@ ...> wrote:
>
> First of all this is a pretty useless interview question.
> Doesn't check any c skills.
>
> And again the solution given below will not execute the
> "else" part!
>
> --SantoshV.
>
> On Wed, Dec 31, 2008 at 9:55 AM, Chetna Bhute <chetnabhute@ ...>
wrote:
>
> > i guess ur interviewer was looking at following answer:
> >
> > if (a=10) /*note: a=10 will not do any comparison but
assignment*/
> > printf("In if part...");
> > else
> > printf("In else part...");
> >
> > On Fri, Dec 26, 2008 at 3:24 PM, kirtibeniwal
<kirtibeniwal@ ...<kirtibeniwal %40yahoo. com>
> > >wrote:
> >
> >
> > > HI I HAVE A QUESTION IN MY MIND ABOUT C LANGUAGE SINCE A MONTH
I HOPE
> > > U WILL SURELY ANSWER MY QUESTION.
> > > "IN C PROGRAM CONTAING IF-ELSE CONDITION IS THERE ANY
STATEMENT WHICH
> > > WILL ENABLE THE COMPLIER TO EXECUTE BOTH IF AND ELSE
STATEMENT?"
> > > THIS WAS THE QUESTION ASKED BY SOME EXTERNAL DURING PLACEMENTS
IN SOME
> > > COLLEGE.
> > > I AM VERY EAGER TO KNOW THE ANSWER. PLEASE REPLY SOON.
> > > KIRTIBENIWAL
> > >
> > >
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>
Add more friends to your messenger and enjoy! Go to
http://messenger.yahoo.com/invite/
[Non-text portions of this message have been removed]