Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > frequently asked C and C++ interview questions along with their answers

Reply
Thread Tools

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

 
 
rohi
Guest
Posts: n/a
 
      07-17-2004
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.


http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      07-17-2004
On Sat, 17 Jul 2004 03:11:02 -0400, rohi
<(E-Mail Removed)> 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.
> (E-Mail Removed)
>


I searched on google for C++ interview questions

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

You could have done the same.

John
 
Reply With Quote
 
 
 
 
Stone Lan
Guest
Posts: n/a
 
      07-17-2004
seems that the interviewers are always liking the questions about Pointer
"rohi" <(E-Mail Removed)> 写入消息新闻
:(E-Mail Removed) 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.
>
>
> (E-Mail Removed)
>
>
>



 
Reply With Quote
 
Spacen Jasset
Guest
Posts: n/a
 
      07-17-2004
"rohi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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;



 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      07-17-2004
On Sat, 17 Jul 2004 12:51:30 +0100, Spacen Jasset
<(E-Mail Removed)> wrote:

> "rohi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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
 
Reply With Quote
 
Lorenzo Dieryckx
Guest
Posts: n/a
 
      07-17-2004
On Sat, 17 Jul 2004 03:11:02 -0400, "rohi" <(E-Mail Removed)> 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
 
Reply With Quote
 
Spacen Jasset
Guest
Posts: n/a
 
      07-17-2004

"John Harrison" <(E-Mail Removed)> wrote in message
newspsa97fra5212331@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.


 
Reply With Quote
 
Julie
Guest
Posts: n/a
 
      07-17-2004
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.
 
Reply With Quote
 
Julie
Guest
Posts: n/a
 
      07-17-2004
Lorenzo Dieryckx wrote:
>
> On Sat, 17 Jul 2004 03:11:02 -0400, "rohi" <(E-Mail Removed)> 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++.
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      07-17-2004
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: frequently asked C and C++ interview questions along with their answers Snyke C++ 3 07-19-2004 03:12 PM
Re: frequently asked C and C++ interview questions along with their answers Minti C++ 0 07-19-2004 12:08 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit C Programming 0 08-01-2003 10:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit C Programming 0 07-01-2003 10:00 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit C Programming 0 07-01-2003 10:00 AM



Advertisments