By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

C question -- Know the answers to the following

P: n/a
Know the answers to the following?

Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed? Under
what conditions might this not be so?

2. Is there an alternative, but equivalent, way to write line
2000? If so, what is it?

3. Is getbuf() a reasonable function?

4. Will getbuf() execute at all?

5. Please comment on line 2051.

6. Is getbuf() good practice, and why?

7. What line not given should be provided for compilation?

8. How, exactly, could one get a second 'char*' to use back from
this function? Be specific in terms of the exact syntax needed. (That
is, provide code.) Another way to state this question is how can this
function be modified to return a 'char*' (that is, it maintains the
same return type) from the function, and an additional 'char *' value
in one function call. Please make sure that your answer will work even
if the size of the char * desired is not known in the outside calling
function. Avoid (do no use) C++ syntax. Include statement in called and
calling functions. Use food programming practice.

9. For those candidates who know SQL: There is a table with
gene_ids ('gid') and clone_ids ('cid'). Each gene only resides on a
single clone and each clone may contain multiple genes. How do would
you find how many genes are on each and every clone? Please provide the
SQL.

10. What's the difference between system calls and library functions?

Nov 15 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
ml*****@gmail.com wrote:
Know the answers to the following?

<snip>
Yes. Except 5, since that's not a question.

Do you? If not, better study harder.

I will say the questions provided are pretty stupid. I'd think twice
before going to work or study at a place giving such examinations.

S.
Nov 15 '05 #2

P: n/a

ml*****@gmail.com wrote:
[obvious homework questions snipped]

In the future, if you want help with your homework, it would be best
not to cut and paste the assignment verbatim, and you should have at
least *tried* to answer the questions on your own.

If you do not understand any of the questions, or if you would like us
to comment on your answers, feel free to ask for help. But do not
expect us to do your homework for you.

Nov 15 '05 #3

P: n/a
ml*****@gmail.com wrote
(in article
<11**********************@o13g2000cwo.googlegroups .com>):
Know the answers to the following?


Do your own homework. Have you no shame?

--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #4

P: n/a
ml*****@gmail.com wrote:
Know the answers to the following?

Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed? Under
what conditions might this not be so?


<snip>

If you really posted your homework verbatim, then I think the setter
should fail the exam.
--
Nick Keighley

"To every complex problem there is a simple solution...
and it is wrong"
-- Turski

Nov 15 '05 #5

P: n/a
Nick Keighley wrote:
ml*****@gmail.com wrote:
Know the answers to the following?

Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed? Under
what conditions might this not be so?

<snip>

If you really posted your homework verbatim, then I think the setter
should fail the exam.

The answer, of course, being "nasal demons, unless hell has frozen over
and they're all at the ice rink".

Alternatively, "it's not line 201 that should be executed, it's you, and
your compiler has the right to do so".

S.
Nov 15 '05 #6

P: n/a


ml*****@gmail.com wrote On 10/03/05 16:15,:
Know the answers to the following?
Yes.
Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed? Under
what conditions might this not be so?
1a: Line 201 will not be executed. 1b: Because of
(1a), "under all conditions" it is meaningless to speak
of the value of `q'.
2. Is there an alternative, but equivalent, way to write line
2000? If so, what is it?
2a: Yes. 2b: The words "is it" betray a lack of
understanding of C, and should be replaced by "are they."
3. Is getbuf() a reasonable function?
No. C has no notion of "reason" or "reasonable" or
"reasonability."
4. Will getbuf() execute at all?
No.
5. Please comment on line 2051.
It's shorter than "War and Peace."
6. Is getbuf() good practice, and why?
6a: No. 6b: Because it's bad practice.
7. What line not given should be provided for compilation?
Once again, the use of the singular instead of the
plural shows that the questioner doesn't know C. Alternate
answer: "cc filename.c".
8. How, exactly, could one get a second 'char*' to use back from
this function? Be specific in terms of the exact syntax needed. (That
is, provide code.) Another way to state this question is how can this
function be modified to return a 'char*' (that is, it maintains the
same return type) from the function, and an additional 'char *' value
in one function call. Please make sure that your answer will work even
if the size of the char * desired is not known in the outside calling
function. Avoid (do no use) C++ syntax. Include statement in called and
calling functions. Use food programming practice.
Which function? Also, how can the size of a `char*' be
unknown, anywhere, since it's always `sizeof(char*)'? Finally,
how hungry was the person who wrote the question?
9. For those candidates who know SQL: There is a table with
gene_ids ('gid') and clone_ids ('cid'). Each gene only resides on a
single clone and each clone may contain multiple genes. How do would
you find how many genes are on each and every clone? Please provide the
SQL.
Off-topic.
10. What's the difference between system calls and library functions?


Library functions exist, system calls do not.

--
Er*********@sun.com

Nov 15 '05 #7

P: n/a

ml*****@gmail.com schreef:
Know the answers to the following?


Ok. I'll play...

<snip all my answers>

Ok. i played. It was simple. It was simple, too, to realize i'm doing
your homework.

Nov 15 '05 #8

P: n/a
Here is my answer is that correct?
1. What will be in variable 'q' after line 201 is executed? Under what
conditions might this not be so?

aln >> content of b, of which is probably garbage. under some weird
circumstances (eg, snippit within a func that doesn't do garbage
collection and loops around) b might be last known value. if this was
java, i think b might get init to null automagically.

2. Is there an alternative, but equivalent, way to write line 2000? If
so, what is it?

aln >> int get_string(char *buff)

3. Is getbuf() a reasonable function?

aln >> i think so but the answer is probably not because of something
to do with a non-static array being casted as a string ptr, right?

4. Will getbuf() execute at all?

aln >> probably not; intuition not based on logical understanding of c
but on "feel" of questions from 3) thru 6).

5. Please comment on line 2051.

aln >> casting to char * for local array probably wont show anything at
all; content only avail w/in scope of func, right?

6. Is getbuf() good practice, and why?

aln >> see 5) above.

7. What line not given should be provided for compilation?

aln >> dont know.

8. How, exactly, could one get a second 'char*' to use back from this
function? Be specific in terms of the exact syntax needed. (That is,
provide code.) Another way to state this question is how can this
function be modified to return a 'char*' (that is, it maintains the
same return type) from the function, and an additional 'char *' value
in one function call. Please make sure that your answer will work even
if the size of the char * desired is not known in the outside calling
function. Avoid (do no use) C++ syntax. Include statement in called and
calling functions. Use good programming practice.

aln >> no idea...

9. For those candidates who know SQL: There is a table with gene_ids
('gid') and clone_ids ('cid'). Each gene only resides on a single clone
and each clone may contain multiple genes. How do would you find how
many genes are on each and every clone? Please provide the SQL.

aln >> yikes i dont remember anything i learned (and haven't used in) 6
years ago!!!

10. What's the difference between system calls and library functions?

aln >> 1st attempt a: system calls is invoked at runtime when applic
func is called. library functions are incorp into object as defined and
referenced func calls and ck'ed at compile time; ie, lib functions
exists in object code, whereas sys calls are (may be?) undefined?

2nd attempt b: sys call affects os (eg, lo level kernel stuff routines)
whereas lib func may act as liason between app and sys call else just
another func call to existing library of common routines. eg printf is
libr func and the content of printf has sys calls...

Nov 15 '05 #9

P: n/a

Greetings, ml*****@gmail.com
I am the hiring manager for the C assessment that you so boldy
displayed on the internet and FYI I will be removing your candidacy
from our application process as you are obviously not qualified for
this position as you are unable to answer questions by yourself. Moral
of the story...remember you're using the INTERNET DUH!:(
--
RecruitC++Message posted via http://www.exforsys.com for all your training needs.

Nov 15 '05 #10

P: n/a
hi there, if u have the answers for those questions would u mind to
share with me, i have my, and not sure if they are right, so msg me if
u want see my answers.
ml*****@gmail.com wrote:
Know the answers to the following?

Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed? Under
what conditions might this not be so?

2. Is there an alternative, but equivalent, way to write line
2000? If so, what is it?

3. Is getbuf() a reasonable function?

4. Will getbuf() execute at all?

5. Please comment on line 2051.

6. Is getbuf() good practice, and why?

7. What line not given should be provided for compilation?

8. How, exactly, could one get a second 'char*' to use back from
this function? Be specific in terms of the exact syntax needed. (That
is, provide code.) Another way to state this question is how can this
function be modified to return a 'char*' (that is, it maintains the
same return type) from the function, and an additional 'char *' value
in one function call. Please make sure that your answer will work even
if the size of the char * desired is not known in the outside calling
function. Avoid (do no use) C++ syntax. Include statement in called and
calling functions. Use food programming practice.

9. For those candidates who know SQL: There is a table with
gene_ids ('gid') and clone_ids ('cid'). Each gene only resides on a
single clone and each clone may contain multiple genes. How do would
you find how many genes are on each and every clone? Please provide the
SQL.

10. What's the difference between system calls and library functions?


Nov 15 '05 #11

P: n/a
ml*****@gmail.com wrote:

<snip>
Use food programming practice.

/* Example of poor food programming */
char izo_burrito, and_a;
double tequila, please;
(void) bowels();
Is that the right answer? What did I win?
Mark F. Haigh
mf*****@sbcglobal.net

Nov 15 '05 #12

P: n/a
In article <11**********************@g49g2000cwa.googlegroups .com>,
appletree <an************@yahoo.com> wrote:
Use food programming practice.


For hints see http://reid_j.tripod.com/foodprog.html

-- Richard
Nov 15 '05 #13

P: n/a
"appletree" <an************@yahoo.com> writes:
hi there, if u have the answers for those questions would u mind to
share with me, i have my, and not sure if they are right, so msg me if
u want see my answers.
ml*****@gmail.com wrote:
Know the answers to the following?

Line Contains

50 char *b, q, *r;
200 b = getbuf ();
201 q = *b;
212 R = anotherfunction (b);
213-2003 /* we want to use 'q' and 'r' here */
2000 char * getbuf ()
2001 {
2002 char buff [8];
2003-2050 /* unspecified buff defined here */
2051 return (char*) buff;
2052 }

1. What will be in variable 'q' after line 201 is executed?
Bits.
what conditions might this not be so?
If the program is run on a trinary computer.
2. Is there an alternative, but equivalent, way to write line
2000?
Yes.
If so, what is it?
"line MM"
3. Is getbuf() a reasonable function?
It's eminently reasonable; after all, it has no arguments.
4. Will getbuf() execute at all?
Never. It's morally opposed to the death penalty. (This is a trick
question; if you haven't met getbuf() personally, you probably won't
know this.)

5. Please comment on line 2051.
I really like the monospaced font.
6. Is getbuf() good practice, and why?
It's undoubtedly good practice for something.
7. What line not given should be provided for compilation?
"Hey, baby, do you compile around here often?"
8. How, exactly, could one get a second 'char*' to use back from
this function? Be specific in terms of the exact syntax needed. (That
is, provide code.) Another way to state this question is how can this
function be modified to return a 'char*' (that is, it maintains the
same return type) from the function, and an additional 'char *' value
in one function call. Please make sure that your answer will work even
if the size of the char * desired is not known in the outside calling
function. Avoid (do no use) C++ syntax. Include statement in called and
calling functions. Use food programming practice.
return (char*) buff + 'char*'; /* with a side order of onion rings */
9. For those candidates who know SQL: There is a table with
gene_ids ('gid') and clone_ids ('cid'). Each gene only resides on a
single clone and each clone may contain multiple genes. How do would
you find how many genes are on each and every clone? Please provide the
SQL.
SQL://ACACACATCAGCATATCCAACACAAGAATTGGGCACACGTAA/
10. What's the difference between system calls and library functions?


3.7 microseconds. Less on newer CPUs.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #14

P: n/a
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
3. Is getbuf() a reasonable function?


It's eminently reasonable; after all, it has no arguments.


Keith! Actual humor?! Next you'll be spouting Zen! ;-)

--
Mabden
Nov 15 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.