Good C Interview ques 
Author Message
 Good C Interview ques


[snip]

Quote:
>Here's a question:
>Write a function which converts a number from an arbitrary base between
>2 and 9 to base 10.  Assume the input is a valid number in the input
>base, and the base is always between  2 and 9.
>/* spec: */ int convert(int number, int base);

I must admit not having the slightest idea what this question means,
since the input int and the output int are base 2 on a binary machine.

A function with a prototype
    int convert(char *outputString, const char *inputString, int base);
with the return value being a completion code makes more sense to me.
But since this is trivial with standard C functions, it would serve only
as a rudimentary screening question.

[snip]

--

* Chicago, IL (USA)    



Mon, 03 Aug 1998 03:00:00 GMT  
 Good C Interview ques


Quote:

>> Write a function which converts a number from an arbitrary base between
>> 2 and 9 to base 10.  Assume the input is a valid number in the input
>> base, and the base is always between  2 and 9.
>> /* spec: */ int convert(int number, int base);

MA> I must admit not having the slightest idea what this question
MA> means, since the input int and the output int are base 2 on a
MA> binary machine.

An example call would be:

  base10 = convert(1567, 8);

base10 should contain the value equal to: 7 + 6*8 + 5*8*8 + 1*8*8*8

-- James

[Oh, you mean strtol((sprintf(buf, "%d", 1567),buf), 0, 8) -mod]



Sun, 09 Aug 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Good C Interview ques

2. C++ ques. for job interview

3. C++ ques. for job interview

4. Good C Interview questions?

5. Good Interview

6. Looking for good textbook for CS course

7. Good CS Programs

8. Exams at job interviews (Re: Interview question)

9. MICROSOFT INTERVIEW QUESTIONS (was Re: Interviewing at Microsoft)

10. MICROSOFT INTERVIEW QUESTIONS (was Re: Interviewing at Microsoft

11. MICROSOFT INTERVIEW QUESTIONS (was Re: Interviewing at Microsoft)

12. MICROSOFT INTERVIEW QUESTIONS (was Re: Interviewing at Microsoft)

 

 
Powered by phpBB® Forum Software