1000 C,C++,RDBMS,Unix,OS Interview Questions And Answers

  • Thread starter softwareengineer2006
  • Start date
A

Andrew Koenig

http://www.geocities.com/online_learning_qa
So please have a look and make use of it.

Don't bother.

What you'll find will be pages full of advertising with interspersed links
to (unclassified) "interview questions." If you follow those links, you
will find lists of (again unclassified) questions combined with answers that
are sometimes correct. Sometimes the question is on one page and the answer
on another.

For example, the question that ends
http://www.geocities.com/online_learning_qa/OnlineLearning-11.htm is

main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}

I guess this is intended as a C problem, because there's no return type.
For that matter, there's no declaration for printf.

Anyway, most readers should immediately realize that the result
of executing this program is undefined, because it modifies the
variable "i" more than once between sequence points.

The recommended "answer," which appears on
http://www.geocities.com/online_learning_qa/OnlineLearning-12.htm, is

Answer:
45545
Explanation:
The arguments in a function call are pushed into the stack from left to
right. The evaluation is by popping out from the stack. and the evaluation
is from right to
left, hence the result.

This is, of course, nonsense. Worse than that, it is dangerous nonsense,
because if you happen to be using an implementation that behaves this
way consistently, you might be lulled into believing that all
implementations
behave this way, and therefore write programs with errors that testing
on your implementation can never reveal.


I found this error by looking through the text at random, so I am quite
confident
that there are others of similar magnitude.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,998
Messages
2,570,242
Members
46,834
Latest member
vina0631

Latest Threads

Top