Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   frequently asked C and C++ interview questions along with their answers (http://www.velocityreviews.com/forums/t284429-frequently-asked-c-and-c-interview-questions-along-with-their-answers.html)

rohi 07-17-2004 07:11 AM

frequently asked C and C++ interview questions along with their answers
 
dear friends,

I have applied for a job in a software company.
a friend of mine told me that the written test will basically contain
questions from C & C++.I would be happy if someone could please send some
basic interview questions asked in C and C++ along with their answers.

Thanking you.


rohit_archer22@nospam.yahoo.co.in




John Harrison 07-17-2004 07:18 AM

Re: frequently asked C and C++ interview questions along with their answers
 
On Sat, 17 Jul 2004 03:11:02 -0400, rohi
<rohit_archer22@nospam.yahoo.co.in> wrote:

> dear friends,
>
> I have applied for a job in a software company.
> a friend of mine told me that the written test will basically contain
> questions from C & C++.I would be happy if someone could please send some
> basic interview questions asked in C and C++ along with their answers.
> Thanking you.
> rohit_archer22@nospam.yahoo.co.in
>


I searched on google for C++ interview questions

http://www.google.com/search?ie=UTF-...view+questions

You could have done the same.

John

Stone Lan 07-17-2004 07:54 AM

Re: frequently asked C and C++ interview questions along with their answers
 
seems that the interviewers are always liking the questions about Pointer
"rohi" <rohit_archer22@nospam.yahoo.co.in> 写入消息新闻
:e61d9dc0a742480874c7d85857ff1b9a@localhost.talkab outprogramming.com...
> dear friends,
>
> I have applied for a job in a software company.
> a friend of mine told me that the written test will basically contain
> questions from C & C++.I would be happy if someone could please send some
> basic interview questions asked in C and C++ along with their answers.
>
> Thanking you.
>
>
> rohit_archer22@nospam.yahoo.co.in
>
>
>




Spacen Jasset 07-17-2004 11:51 AM

Re: frequently asked C and C++ interview questions along with their answers
 
"rohi" <rohit_archer22@nospam.yahoo.co.in> wrote in message
news:e61d9dc0a742480874c7d85857ff1b9a@localhost.ta lkaboutprogramming.com...
> dear friends,
>
> I have applied for a job in a software company.
> a friend of mine told me that the written test will basically contain
> questions from C & C++.I would be happy if someone could please send some
> basic interview questions asked in C and C++ along with their answers.

....

The 3 that I was asked at an interview the other day were these. I don't
necessarily consider them good quesitons.
Infact I won't post the 3rd one. Interview questions vary a lot, and
sometimes arn't really about C. ( i.e. what is a thread and what
compications arise in using them )


1) These files are compiled and linked toghether.

/* File: c1.c */

#include <stdio.h>

extern char *str;

int main()
{
printf("%s\n", str );
getchar();
return 0;
}

/* File: c2.c */

char str[] = "Hello world";

What's wrong here?


2) If an int x, is known to have the value 1 or 2. Assign x the value 1 to x
when x is 2, and 2 when x is 1. Use the shortest possible code snippet.

2a) If x is a float, do the same as above


Answers:

1) extern char *str is a declaration that specifies str as external and is a
pointer to str, whereas infact str is a character array, so use extern char
str[];


2) X ^=3;
2a) x = 3 - x;




John Harrison 07-17-2004 12:24 PM

Re: frequently asked C and C++ interview questions along with their answers
 
On Sat, 17 Jul 2004 12:51:30 +0100, Spacen Jasset
<spacenjasset@yahoo.co.uk> wrote:

> "rohi" <rohit_archer22@nospam.yahoo.co.in> wrote in message
> news:e61d9dc0a742480874c7d85857ff1b9a@localhost.ta lkaboutprogramming.com...
>> dear friends,
>>
>> I have applied for a job in a software company.
>> a friend of mine told me that the written test will basically contain
>> questions from C & C++.I would be happy if someone could please send
>> some
>> basic interview questions asked in C and C++ along with their answers.

> ...
>
> The 3 that I was asked at an interview the other day were these. I don't
> necessarily consider them good quesitons.
> Infact I won't post the 3rd one. Interview questions vary a lot, and
> sometimes arn't really about C. ( i.e. what is a thread and what
> compications arise in using them )
>
>
> 1) These files are compiled and linked toghether.
>
> /* File: c1.c */
>
> #include <stdio.h>
>
> extern char *str;
>
> int main()
> {
> printf("%s\n", str );
> getchar();
> return 0;
> }
>
> /* File: c2.c */
>
> char str[] = "Hello world";
>
> What's wrong here?
>
>
> 2) If an int x, is known to have the value 1 or 2. Assign x the value 1
> to x
> when x is 2, and 2 when x is 1. Use the shortest possible code snippet.
>
> 2a) If x is a float, do the same as above
>


[snip]


What beats me is why anyone would think that this sort of trivia can
distinguish good programmers from bad programmers.

What about (off the top of my head)

1) Under what circumstances would you consider using a global variable?

2) One of your classes needs to be able to access an instance of another
of your classes. What are the benefits and costs of the following two
possibilites

class A
{
...
private:
B* b_ptr;
};

class A
{
...
private:
B b_obj;
};

3) Would you ever use public data members? If so when?

You know questions about stuff that actually matters when you are
programming.

john

Lorenzo Dieryckx 07-17-2004 12:54 PM

Re: frequently asked C and C++ interview questions along with their answers
 
On Sat, 17 Jul 2004 03:11:02 -0400, "rohi" <rohit_archer22@nospam.yahoo.co.in> wrote:

>dear friends,
>
> I have applied for a job in a software company.
>a friend of mine told me that the written test will basically contain
>questions from C & C++.I would be happy if someone could please send some
>basic interview questions asked in C and C++ along with their answers.
>
> Thanking you.
>


int main()
{
int * x;

*x = 10;
return 0;
}

// What's wrong here?

They have asked this in _every_ interview that I did,
and if you don't know the answer, don't apply for
a software job :-)

--
Lorenzo Dieryckx
mail: lorenzodotdieryckxatpandoradotbe

Spacen Jasset 07-17-2004 02:04 PM

Re: frequently asked C and C++ interview questions along with their answers
 

"John Harrison" <john_andronicus@hotmail.com> wrote in message
news:opsa97fra5212331@andronicus...

....

> What beats me is why anyone would think that this sort of trivia can
> distinguish good programmers from bad programmers.
>

....

Yes, it's true. I think the best interviews are those that ask a variety of
questions. 3 questions arn't really enough. And in my opinion good C
knowledge is not necessarily enough -- but on the other hand if you have
good C knoweledge then you are likly to be more rounded since you've had to
spend time learning about all sort of things while putting C to use.

Some interview questions I don't agree with either -- or I mean don't quite
agree with the answer.



Julie 07-17-2004 03:08 PM

Re: frequently asked C and C++ interview questions along withtheir answers
 
rohi wrote:
>
> dear friends,
>
> I have applied for a job in a software company.
> a friend of mine told me that the written test will basically contain
> questions from C & C++.I would be happy if someone could please send some
> basic interview questions asked in C and C++ along with their answers.


You may consider this a little harsh, but with an attitude like this, you won't
or shouldn't get hired.

Being a successful programmer means that you dedicate yourself to personal (and
team) improvement -- a 'go-getter' attitude is key.

What you should be doing in this case is: making up questions on your own --
really think about the questions and why or why they aren't appropriate, then
research the various answers.

Julie 07-17-2004 03:19 PM

Re: frequently asked C and C++ interview questions along withtheir answers
 
Lorenzo Dieryckx wrote:
>
> On Sat, 17 Jul 2004 03:11:02 -0400, "rohi" <rohit_archer22@nospam.yahoo.co.in> wrote:
>
> >dear friends,
> >
> > I have applied for a job in a software company.
> >a friend of mine told me that the written test will basically contain
> >questions from C & C++.I would be happy if someone could please send some
> >basic interview questions asked in C and C++ along with their answers.
> >
> > Thanking you.
> >

>
> int main()
> {
> int * x;
>
> *x = 10;
> return 0;
> }
>
> // What's wrong here?


Absolutely nothing is wrong. All of the above is perfectly legal C++.

osmium 07-17-2004 03:39 PM

Re: frequently asked C and C++ interview questions along with their answers
 
Julie writes:

> > int main()
> > {
> > int * x;
> >
> > *x = 10;
> > return 0;
> > }
> >
> > // What's wrong here?

>
> Absolutely nothing is wrong. All of the above is perfectly legal C++.


Only a fool would give that answer if he wanted the job. If you don't want
to work there, why bother with the interview?

They are hiring programmers, not language lawyers.




All times are GMT. The time now is 01:25 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.