473,765 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i need some C/C++ test intervie questions

hello everyone,
Iam vasant from India..
I have a test+interview on C /C++ in the coming month so plz help me
by giving some resources of FAQS, interview questions, tracky
questions, multiple choice questions.etc..
I'll be indebted to everyone..
Thanks in advance..
regards
vasant shetty
Bangalore
India
Nov 13 '05
162 14899
Tom Zych, 9/4/2003 5:06 PM:
Denis Perelyubskiy177 0880499 wrote:

I started reading this book: http://makeashorterlink.com/?L1D922DC5

Hmm. 38 characters. Not bad, but if you want a really tiny URL,
there's http://www.tinyurl.com/ . Generally about half as long.


Ah, yes. And they have a neat bookmarklet, saving you time. Pretty
cool. :)

denis

--
'From' email address is used as a sink. Not read. Ever.
Instead, send to [p-o-s-t-i-n-g|o-v-e-r-w-h-e-l-m|n-e-t]
(remove dashes, replace the first vertical bar with @,
and second with a dot). Sorry for any inconvenience.

Nov 13 '05 #101
"Kevin D. Quitt" wrote:
.... snip ...
I doubt I'd be interviewing any of you, and if I were, it wouldn't
include the test. More along the lines of "You can't do any
better than here?".


You mean you are hiring? I can be bought. :-)

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #102
Ben Pfaff wrote:
Martin Dickopp <ex************ *@zero-based.org> writes:
Out of curiosity, would you allow the applicant to look into
the C standard? After all, I can also consult the standard
while actually programming.


Out of curiosity, how many people actually do this? I know that
I fairly often refer to it myself while programming and have even
cited bits of it in debates at the office (VMware at the moment,
Stanford later this month).


I do, routinely. I have an alias setup to access (more or less)
the relevant portions, which is why I want a text version of the
standard. N869 comes to mind. The machinery seems to have a
better memory than mine.

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #103
Richard Heathfield wrote:
.... snip ...
Okay, I'm listening. Here's the question: is the behaviour of
this program well-defined?

#include <stdio.h>
#include <ctype.h>

int main(void)
{
char buf[] = "hello world";
char *p = buf;
p[-1] = (toupper)(*p++) ; /* This is the trouble spot. */
printf("%s\n", buf);
return 0;
}

When I first saw this, I thought "no way". Then, after discussions
with a clc regular and much thumbing of the Standard, I began to
come to the conclusion that it might be okay (for suitably
pedantic values of "okay", obviously -- the code sucks, after all).

But I'm no longer certain, because... well, never mind! Is it
well-defined? If so, why? If not, why not?


No way. The destination p[-1] *may* be calculated on the
statement entry value of p, which will create an illegal pointer
before the actual storage.

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #104
Kevin Easton wrote:
Richard Heathfield <do******@addre ss.co.uk.invali d> wrote:
Martin Dickopp wrote:
Richard Heathfield <do******@addre ss.co.uk.invali d> writes:

Consult the standard during office debates? Well, it's rare. The usual
reaction to "let me just show you the bit..." is "Rich! Rich! We
***believe*** you, okay?!?!?!?!?!"

I just /hate/ it when people believe me. I don't want them to believe
me, I want them to believe the facts, even if I have stated the facts
correctly.
Yes, the difficulty is when you give a confident answer, they go off
happily, and then later you realise that perhaps it wasn't as clear-cut
as you thought.
Therefore, when somebody asks me a question, I usually insist that he
listens to the complete answer, which often involves quoting from the
standard. ;)


Okay, I'm listening. Here's the question: is the behaviour of this
program well-defined?

#include <stdio.h>
#include <ctype.h>

int main(void)
{
char buf[] = "hello world";
char *p = buf;
p[-1] = (toupper)(*p++) ; /* This is the trouble spot. */
printf("%s\n", buf);
return 0;
}

When I first saw this, I thought "no way". Then, after discussions with a
clc regular and much thumbing of the Standard, I began to come to the
conclusion that it might be okay (for suitably pedantic values of "okay",
obviously -- the code sucks, after all).

But I'm no longer certain, because... well, never mind! Is it
well-defined? If so, why? If not, why not?


Surely not, because the indicated line both modifies p and uses its
value for a purpose other than calculating its new value without an
intervening sequence point (the sequence point before the function call
is not necessarily intervening, because there isn't a total ordering
between the modification and use of p).


That was quick. You're right in that the "timing" of the sequence point is
vital to the answer.
If that doesn't convince you,
This is the trouble. I was convinced twice already, in opposite directions.
:-)
the above is equivalent to (by the
definition of the [] operator):

*(p - 1) = (toupper)(*p++) ;

...and there is nothing to prevent this ordering:

Calculate p - 1 => temp 1
Calculate p + 1 => temp 2
Fetch value pointed to by temp 2 => temp 3
Store temp 2 into p
Call toupper function with temp 3 as argument
Store result into object pointed to by temp 1

(The order of evaluation of the subexpressions making up the operands to
the = operator isn't defined).


That's basically the only way to break it, I think. I'll have another plough
through C99 next time I get a chance.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #105
Richard Heathfield <do******@addre ss.co.uk.invali d> writes:
Okay, I'm listening. Here's the question: is the behaviour of this program
well-defined?

#include <stdio.h>
#include <ctype.h>

int main(void)
{
char buf[] = "hello world";
char *p = buf;
p[-1] = (toupper)(*p++) ; /* This is the trouble spot. */
printf("%s\n", buf);
return 0;
}


This is certainly an example where I would have quoted the standard if I'd
been the first to answer. :)

First of all, `p' is obviously modified and used to determine the
/location/ to be stored to (as opposed to the value to store), so the
behavior is undefined according to 6.5#2 /unless/ there's an intervening
sequence point. It remains to be shown that the sequence point before the
`toupper' call is not guaranteed to happen between these two operations.
According to 6.5#3, "the order of evaluation of subexpressions and the
order in which side effects take place are both unspecified."

Martin
Nov 13 '05 #106
Bill Reed wrote:
On Wed, 3 Sep 2003 10:32:51 -0500, Randy Howard
jd********@ntl world-not.com says...
Kevin D. Quitt wrote:

> As an occasional interviewer, I find I have to give a test.
> The first question asks the applicant to rate their knowledge
> of C from 1 to 10, where 1 is "What's C?" and 10 is "I'm
> Dennis Ritchie". I use this to set my expectation of the
> results from the rest of the test.

What if the reply is "Who?" ?


*gasp*

You're right. "Who is Dennis Ritchie?"


Didn't he have something to do with the Commodores?


Illustrating the foolishness of such a question. It has nothing
to do with the programmers abilities, but much to do with his
historical knowledge, curiosity, and exposure. In this country
(USA) at least, asking the man/woman in the street simple
historical questions, or even geographical questions, can produce
the most amazing gaffes. Leno takes advantage of this to
generate humor on his program.

I cannot remember the name offhand (I will refer to him as R),
but there was an Indian mathematician, totally untutored, who
wrote GH Hardy with some observations, and was thus discovered as
a major mathematical force. Hardy brought R to Cambridge (or
Oxford??) and R made major contributions to the mathematical
world. However R initially knew absolutely nothing about the
historical development and contributors to mathematics, such as
Newton, Gauss, Dedekind, and many others.

--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Nov 13 '05 #107
Richard Heathfield wrote:
...is the behaviour of this program well-defined?

#include <stdio.h>
#include <ctype.h>

int main(void)
{
char buf[] = "hello world";
char *p = buf;
p[-1] = (toupper)(*p++) ; /* This is the trouble spot. */
printf("%s\n", buf);
return 0;
}


I'm not a standard C guru (yet). My answer is, it doesn't matter,
because even if one can dig into the standard and show that this
works reliably, it's bad code. You can't tell if it works without
being a language lawyer, and it offers no advantage over clear and
reliable code. It should be rewritten and the original coder
should be shot[1].

[1] If it had been in actual production code instead of a puzzle,
that is.

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk. pbz' | rot13
Nov 13 '05 #108
oz****@spamenot .bigpond.com (ozbear) wrote:
On Tue, 02 Sep 2003 22:41:56 GMT, qe*@pobox.com (Paul Hsieh) wrote:
do**********@s pamhate.com says...
Personally, in my job hunting days, I walked out on an interviewer that
presumed to give me a test. I find the practice insulting.
I only wish all candidates who objected to being tested would do this -- I
hate wasting my time with the likes of people like you.


Ditto.

If any sort of "exam" is to be part of an interview, it should be
stated beforehand.


I would expect an "exam" from any interview. When *I* am interviewed,
I generally think twice before accepting a position where I have not
been tested (because it means my coworkers were not tested, and
therefore may be of questionable skill ...)
Those of us who have been in the game for decades find this sort of
practice demeaning,
For me, its completely the opposite. In the time it takes to
interview *I* can only get a fair assessment from an interviewer if I
have been given the opportunity to demonstrate exactly where my skill
level is. If they don't test me, then they are treating me like a
checkbox. I've worked at companies that have taken both points of
view and found that my compensation was usually higher at the places
where I was more seriously scrutinized during the interview.

At two of the companies I've worked for I was *used* as an "acid test"
kind of interviewer, because I had built up a number of standard
questions so that my boss could understand my assessment.
[...] and a good indication that it is a job we don't
want anyway.
I don't know who this "we" is. I find that the length of a person's
career is not any kind of indicator of the skill level of the person I
am interviewing. Often such people have lost touch with leading edge
development ideas.
[...] Therefore, it saves time on both persons' parts.


Agreed.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
Nov 13 '05 #109
LibraryUser wrote:
You're right. "Who is Dennis Ritchie?" Didn't he have something to do with the Commodores?

Illustrating the foolishness of such a question. It has nothing
to do with the programmers abilities, but much to do with his
historical knowledge, curiosity, and exposure. <snip>
I cannot remember the name offhand (I will refer to him as R),
Ramanujan.
but there was an Indian mathematician, totally untutored, who
wrote GH Hardy with some observations, and was thus discovered as
a major mathematical force. Hardy brought R to Cambridge (or
Oxford??) and R made major contributions to the mathematical
world. However R initially knew absolutely nothing about the
historical development and contributors to mathematics, such as
Newton, Gauss, Dedekind, and many others.


An interesting parallel. IIRC, Ramanujan learned from one book and
figured out the rest on his own. You can do that with math[1],
because math is self-contained and deductive. Theoretically, I
suppose one could read one C book (which didn't mention Ritchie or
other C luminaries), then use a compiler and man pages to become
expert.

OTOH, I think curiosity counts for a lot in programming. And
experience is hard to obtain without exposure to a wider body of
literature.

[1] Well, if you're Ramanujan, you can :)

--
Tom Zych
This email address will expire at some point to thwart spammers.
Permanent address: echo 'g******@cbobk. pbz' | rot13
Nov 13 '05 #110

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.