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

Home Posts Topics Members FAQ

What type of questions can be asked in an technical interview of C

Frinds,

Hope everyone is doing fine.i feel pointers to be the most toughest
part in C. i have just completed learning pointers & arrays related
portions. I need to attend technical interview on C. wat type of
questions should be expected? Which part of C language do the staff
give more concern?
The interviewers have just mentioned that .. i will have interview on
C.
Also can anyone can help me with sites where i can go thru sample
programs in C?

Thanking you all...
Cherry
Nov 14 '05 #1
56 4339
Cherrish Vaidiyan <un************ ***@yahoo.com> scribbled the following:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest
part in C. i have just completed learning pointers & arrays related
portions. I need to attend technical interview on C. wat type of
questions should be expected? Which part of C language do the staff
give more concern?
The interviewers have just mentioned that .. i will have interview on
C.
Also can anyone can help me with sites where i can go thru sample
programs in C?


This is impossible to answer specifically, as it would require reading
the company's mind. But I think you're off to a good start with pointers
and arrays. Other topics that can come up are functions (calling and
parameter passing mechanisms), the type system, and preprocessor macros.
The most important rule I can think of is to learn the core language
first, and any possible OS-specific APIs second, if at all. Knowing
which flag to set to make the X widget turn purple is of no use if you
don't know how function calls work.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This is a personnel commuter."
- Train driver in Scientific American
Nov 14 '05 #2
"Cherrish Vaidiyan" <un************ ***@yahoo.com> wrote in

I need to attend technical interview on C. wat type of
questions should be expected?

See if you can answer these.

What is wrong with

1)
#define min(x, y) x < y ? x : y

2)
char str[5] = "Hello";

3)

for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;

4)
if( ch != '.' || ch != ',')

5)
char *foo(int x)
{
char buff[32];
sprintf(buff, "%d", x);
return buff;
}


Nov 14 '05 #3
Malcolm <ma*****@55bank .freeserve.co.u k> scribbled the following:
"Cherrish Vaidiyan" <un************ ***@yahoo.com> wrote in
I need to attend technical interview on C. wat type of
questions should be expected?
See if you can answer these.

What is wrong with 3) for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;


Am I blind or something? Other than doing more work than necessary (and
such slowing the program down) I can find nothing wrong with this.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'I' is the most beautiful word in the world."
- John Nordberg
Nov 14 '05 #4

"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
What is wrong with

3)

for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;


Am I blind or something? Other than doing more work than necessary (and
such slowing the program down) I can find nothing wrong with this.

It shows a rather different problem to the others. Hint, what happens if str
is a very long string?
Nov 14 '05 #5
Joona I Palaste wrote:
3)


for(i=0;i<str len(str);i++)
if(str[i] == 'a')
answer++;

Am I blind or something? Other than doing more work than necessary (and
such slowing the program down) I can find nothing wrong with this.


It is not wrong as such. Problem is that it is in Omega(n^2).
It is a Nilgesqian problem in other words.

--
Thomas.

Nov 14 '05 #6

"Malcolm" <ma*****@55bank .freeserve.co.u k> wrote in message
news:c4******** **@news6.svr.po l.co.uk...
"Cherrish Vaidiyan" <un************ ***@yahoo.com> wrote in

I need to attend technical interview on C. wat type of
questions should be expected?
See if you can answer these.

What is wrong with

1)
#define min(x, y) x < y ? x : y


if x == y it returns y anyway?
2)
char str[5] = "Hello";
no space for string terminating null character
3)

for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;
pass
4)
if( ch != '.' || ch != ',')
always evaluates to false
5)
char *foo(int x)
{
char buff[32];
sprintf(buff, "%d", x);
return buff;
}


returns pointer to local variable which will be destroyed
when the function has finished executing and will not be.

Where can I find more of these?
solutions will be useful.
cheers
cw
Nov 14 '05 #7
code_wrong wrote:
"Malcolm" <ma*****@55bank .freeserve.co.u k> wrote in message
news:c4******** **@news6.svr.po l.co.uk...
"Cherrish Vaidiyan" <un************ ***@yahoo.com> wrote in
I need to attend technical interview on C. wat type of
questions should be expected?

See if you can answer these.

What is wrong with

1)
#define min(x, y) x < y ? x : y

if x == y it returns y anyway?


x == y returns 1 or 0. Need some brackets.

#define min(x, y) ((x) < (y) ? (x) : (y))

2)
char str[5] = "Hello";

no space for string terminating null character


Correct. But that is not always an error. But if it is not a mistake
I would imagine a comment being a very very good idea.
3)

for(i=0;i<str len(str);i++)
if(str[i] == 'a')
answer++;
pass


On every iteration strlen is called. (Yoda speak to avoid starting
a sentence with a function name is always fun). The loop is in
Omega(n^2) instead of Omega(n) where it should be. But it is perfectly
valid C.
4)
if( ch != '.' || ch != ',')

always evaluates to false


Umm, I think you got that the wrong way around?
Just think that ch can never be equal to two things at the
same time.
5)
char *foo(int x)
{
char buff[32];
sprintf(buff, "%d", x);
return buff;
}

returns pointer to local variable which will be destroyed
when the function has finished executing and will not be.


It will not be... A nice turn of phrase, but otherwise correct :)

--
Thomas.

Nov 14 '05 #8
Malcolm wrote:
"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
What is wrong with

3)

for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;


Am I blind or something? Other than doing more work than
necessary (and such slowing the program down) I can find
nothing wrong with this.

It shows a rather different problem to the others. Hint, what
happens if str is a very long string?


It keeps the CPU out of mischief. Still nothing _wrong_ with it.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!

Nov 14 '05 #9

"Malcolm" <ma*****@55bank .freeserve.co.u k> wrote in message
news:c4******** **@news6.svr.po l.co.uk...
"Cherrish Vaidiyan" <un************ ***@yahoo.com> wrote in

I need to attend technical interview on C. wat type of
questions should be expected?
See if you can answer these.

What is wrong with

1)
#define min(x, y) x < y ? x : y


Does not protect against unwanted precedence evaluations. Should be:

#define min(x, y) ( ((x) < (y)) ? (x) : (y) )

I have an extra pair of parens around the logical expression - just part of
my preferred style.

2)
char str[5] = "Hello";
To store "Hello" as a string requires a 6th byte for the terminating null.
Don't know off the top of my head if the compiler will automatically expand
the definition - since it has all the information it needs - or not.

3)

for(i=0;i<strle n(str);i++)
if(str[i] == 'a')
answer++;
Calling strlen() each pass is highly inefficient, but not "wrong". I would
also recommend reversing the operands in the if() statment:

if('a' == str[i])

that way if you goof and make the common mistake of typing '=' instead of
'==' you have just turned a logic error that might be a royal pain to track
down into a syntax error that the compiler will catch immediately.

4)
if( ch != '.' || ch != ',')
Almost certainly a logic error as it will always evaluate as true. Probably
meant to be && operator.

5)
char *foo(int x)
{
char buff[32];
sprintf(buff, "%d", x);
return buff;
}
buff is an automatic variable that is deallocated after foo() finishes
execution.


Nov 14 '05 #10

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

Similar topics

35
404
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on C. wat type of questions should be expected? Which part of C language do the staff give more concern? The interviewers have just mentioned that .. i will have interview on C. Also can anyone can help me with sites where i can go thru sample
3
2031
by: Dougie | last post by:
Hi, I have an interview later in the week and I've been told that I'll be asked technical questions about ASP.NET. The job is for the position of .NET Web developer and I just wondered if any of you guys had any experience of technical interviews of this nature. Many thanks, Doug.
0
3432
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions http://interviewdoor.com/technical/C-Interview-Questions.htm C# Interview Questions http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm C++ Interview Questions http://interviewdoor.com/technical/C++-Interview-Questions.htm
0
2943
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions http://interviewdoor.com/technical/C-Interview-Questions.htm C# Interview Questions http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm C++ Interview Questions http://interviewdoor.com/technical/C++-Interview-Questions.htm
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.