473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C questions

Dear all,

I was going through a C book written by an indian author
the following are the questions given in that book

1) consider the following statement:
s1 : an operator may require an lvalue operand, yet yield an r
value
s2: an operator may accept an rvalue operand , yet gives an lvalue

which of the following is true about s1 and s2

(a) both s1 and s2 are true
(b) only s1 correct
(c) only s2 is correct
(d) both are false

answer is given as (a)

& is one such operator
int n;
*n is lvalue
&n is rvalue

operator operand result
& n is l value &n rvalue

* (p + 1) is r value *(p + 1) lvalue
2) which of the following is false

a) a string has type array of characters
b) a string has storage class static
c) adjacent string literals are concatenated into a single string
d) Concatenation of ordinary and wide string literal is a single
string

answer is given as d option

3)consider the following

process1(int counter)
{

if(counter == 1)
{
char buf[80];
--------------
}
}

process2(int counter)
{
char buff[80];
if(counter == 1)
{
--------
}

}

which one of the following is true

(a) both process require same stack space in all cases
(b) process 1 require more stack space
(c) process 2 require more stack space
(d) stack space for process is not allocated if counter == 1

answer is given as a option

4) consider the following statements

s1: evaluating the address of an object value after indirection is
simply object
s2:evaluating an object value from indirecting after taking its
address is not the object

which of the following is true
(a) only s1
(b) both are correct
(c) only s2 is correct
(d) both are wrong

answer is given as b option

5)which operation require more memory access
(a) branch
(b) conditional code test
(c) shift register right /* what is this ?*/
(d) all are same

answer is given as d option

well what do you folks think of all this stuff ?
Jan 7 '08
23 2771
ja*********@ver izon.net said:
Richard Heathfield wrote:
>so**********@gm ail.com said:
<snip>
...
d) Concatenation of ordinary and wide string literal is a single
string

False - the behaviour is undefined.

C99 Section 6.4.5p4:
"In translation phase 6, the multibyte character sequences specified
by any sequence of adjacent character and wide string literal tokens
are concatenated into a single multibyte character sequence. If any of
the tokens are wide string literal tokens, the resulting multibyte
character sequence is treated as a wide string literal; otherwise, it
is treated as a character string literal."
Thanks for the correction. I did actually check this while composing my
reply, but only in C89 (which is more conveniently searchable for me). C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jan 7 '08 #11
On Mon, 7 Jan 2008 12:25:44 -0600, Richard Heathfield wrote
(in article <Tr************ *************** ***@bt.com>):
C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.
Microsoft's is by no means the only compiler where "diehards" are stuck
with C89 and friends. gcc may /pretend/ to be a c99 compiler, but most
are not fooled.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Jan 7 '08 #12
Randy Howard <ra*********@FO OverizonBAR.net writes:
On Mon, 7 Jan 2008 12:25:44 -0600, Richard Heathfield wrote
(in article <Tr************ *************** ***@bt.com>):
>C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.

Microsoft's is by no means the only compiler where "diehards" are stuck
with C89 and friends.
The needle on my irony detector was bent by Richard Heathfield's
message. Did yours not flicker?

--
Ben.
Jan 7 '08 #13
On Mon, 7 Jan 2008 12:41:26 -0600, Ben Bacarisse wrote
(in article <87************ @bsb.me.uk>):
Randy Howard <ra*********@FO OverizonBAR.net writes:
>On Mon, 7 Jan 2008 12:25:44 -0600, Richard Heathfield wrote
(in article <Tr************ *************** ***@bt.com>):
>>C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.

Microsoft's is by no means the only compiler where "diehards" are stuck
with C89 and friends.

The needle on my irony detector was bent by Richard Heathfield's
message. Did yours not flicker?
Yeah, but the non-regular, non-indoctrinated may find it confusing,
just as they did when he questioned dmr on topicality.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Jan 7 '08 #14
In article <00************ *************** **@news.verizon .net>, Randy
Howard <ra*********@FO OverizonBAR.net writes
>On Mon, 7 Jan 2008 12:25:44 -0600, Richard Heathfield wrote
(in article <Tr************ *************** ***@bt.com>):
>C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.

Microsoft's is by no means the only compiler where "diehards" are stuck
with C89 and friends. gcc may /pretend/ to be a c99 compiler, but most
are not fooled.
Actually most compilers are not full C99 implementations . It depends
weather they are C95+ or C99- as to how they react.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jan 7 '08 #15
Randy Howard wrote:
On Mon, 7 Jan 2008 12:25:44 -0600, Richard Heathfield wrote
(in article <Tr************ *************** ***@bt.com>):
C99
has changed the rules. For those few diehards (such as the Microsoft guys,
for instance) who *still* don't have a C99-conforming implementation and
have to make do with C89/90/95, the behaviour remains undefined.

Microsoft's is by no means the only compiler where "diehards" are stuck
with C89 and friends. gcc may /pretend/ to be a c99 compiler, but most
are not fooled.
For the purposes of this question, gcc's other flaws are irrelevant;
the thing that matters is whether it handles concatenation of narrow
and wide character literals correctly, and according to my tests it
does.
Jan 7 '08 #16
Ben Bacarisse wrote:
Richard Heathfield <rj*@see.sig.in validwrites:
>so**********@gm ail.com said:
>>2) which of the following is false
b) a string has storage class static
Objects have storage classes. A string is not an object per se, but a
collection of contiguous objects.

That is true, but there is a grain of truth in there. The standard
says that the array initialised from the characters in the string
literal has "static storage duration".
Yes, but the statement was about a string, not a string literal.

--
Thad
Jan 8 '08 #17

<so**********@g mail.comwrote in message
news:3e******** *************** ***********@n22 g2000prh.google groups.com...
Dear all,

I was going through a C book written by an indian author
the following are the questions given in that book
Would be interesting for me to know which book this is ?
>
1) consider the following statement:
s1 : an operator may require an lvalue operand, yet yield an r
value
To be specific , the question applies to unary operators only ? Then the &
operator is one such:
&n is a an rvalue. For a binary operators I can think of a == b
2) which of the following is false

a) a string has type array of characters /* it is meant string
literals ?*/
b) a string has storage class static /* it is meant string
literals have internal linkage */
c) adjacent string literals are concatenated into a single string
d) Concatenation of ordinary and wide string literal is a single
string

answer is given as d option
3)consider the following

process1(int counter)
{

if(counter == 1)
{
char buf[80];
--------------
}
}

process2(int counter)
{
char buff[80];
if(counter == 1)
{
--------
}

}

which one of the following is true

(a) both process require same stack space in all cases
(b) process 1 require more stack space
(c) process 2 require more stack space
(d) stack space for process is not allocated if counter == 1

answer is given as a option
most architectures use something like a stack for automatic storage.
but i am not sure if this answer is correct..

>
4) consider the following statements

s1: evaluating the address of an object value after indirection is
simply object
s2:evaluating an object value from indirecting after taking its
address is not the object
*&(x) == x and &*(x) != x
Is this what is meant by the complicated language ??

>
which of the following is true
(a) only s1
(b) both are correct
(c) only s2 is correct
(d) both are wrong

answer is given as b option

5)which operation require more memory access
(a) branch
(b) conditional code test
(c) shift register right /* what is this ?*/
(d) all are same

answer is given as d option
Not a C question. But since none of the instructions are load-store, they
dont do memory access,
the answer is (d).
well what do you folks think of all this stuff ?
Good for embedded programming job interview in india :)
Jan 8 '08 #18
On Jan 8, 10:30 am, "Ravishanka r S" <ravishanka...@ in.bosch.com>
wrote:
<sophia.ag...@g mail.comwrote in message

news:3e******** *************** ***********@n22 g2000prh.google groups.com...
Dear all,
I was going through a C book written by an indian author
the following are the questions given in that book

Would be interesting for me to know which book this is ?
1) consider the following statement:
s1 : an operator may require an lvalue operand, yet yield an r
value

To be specific , the question applies to unary operators only ? Then the &
operator is one such:
&n is a an rvalue. For a binary operators I can think of a == b
2) which of the following is false
a) a string has type array of characters /* it is meant string
literals ?*/
b) a string has storage class static /* it is meant string

literals have internal linkage */
c) adjacent string literals are concatenated into a single string
d) Concatenation of ordinary and wide string literal is a single
string
answer is given as d option
3)consider the following
process1(int counter)
{
if(counter == 1)
{
char buf[80];
--------------
}
}
process2(int counter)
{
char buff[80];
if(counter == 1)
{
--------
}
}
which one of the following is true
(a) both process require same stack space in all cases
(b) process 1 require more stack space
(c) process 2 require more stack space
(d) stack space for process is not allocated if counter == 1
answer is given as a option

most architectures use something like a stack for automatic storage.
but i am not sure if this answer is correct..
4) consider the following statements
s1: evaluating the address of an object value after indirection is
simply object
s2:evaluating an object value from indirecting after taking its
address is not the object

*&(x) == x and &*(x) != x
Is this what is meant by the complicated language ??


which of the following is true
(a) only s1
(b) both are correct
(c) only s2 is correct
(d) both are wrong
answer is given as b option
5)which operation require more memory access
(a) branch
(b) conditional code test
(c) shift register right /* what is this ?*/
(d) all are same
answer is given as d option

Not a C question. But since none of the instructions are load-store, they
dont do memory access,
the answer is (d).
well what do you folks think of all this stuff ?

Good for embedded programming job interview in india :)
The book name is Advanced test in C
and
Embedded System Programming !!!!!!!!!!!

by Ashok .K pathak

some more questions from the book

state whether true or false

1) system can't determine size of the stack before program runs
answer is given as true

2) location of constant string in memory(text area or data area)
may be compiler dependent

answer is given as true
string may be placed in data area of string area depending on
implementation

3)in all cases printf(ptr); and printf("%s",ptr ); will print the same
string,where ptr points to the address of the string

answer is given as false
printf(ptr); fails if ptr contains %
ex:- printf("a%cb"), printf("%s","a% cb"); will print different
strings

4) which of the following is false

(a) a reentrant function may not use variable in a non atomic way
unless they are stored on the stack of the task that called the
function or are other wise the private variable of that task

(b) a reentrant function may not call any other function that are
not reentrant
(c) a reentrant function may not use the hardware in a non atomic
way
(d) a reentrant function may call any other function that are not
reentrant

answer is given as d option

a single copy of code executed by mulltiple tasks and will always
works correctly is called a reentrant code. for example , many task
may call sprintf(),but there is only a single copy of the subroutine
in the system

5)is the following code reentrant?

int j;

void f(void)
{
if(j 10)
{
j = j+1;
printf("%d",j);
}
else
{
j = j-1;
printf("%d",j);
}
}

answer is given as no

violation of rule 1: global variable j is in a fixed loacation in
memory and therefore shared by any tasks that call f.The use of j is
not atomic, because the RTOS might switch tasks between the time it is
tested and the time that it is updated. may violate rule 2 for this
function to reentrant,print f must also be reentrant
6) In a program written in C find the major and minor cycle(rem) ?

main()
{
while(1)
{
proc_w();
proc_x();
proc_w();
proc_y();
proc_w();
proc_x();
proc_w();
proc_z();

}
}
answer is given as

major cycle wxwywxwz
minor cycle wxwz wxwy wx wy wz

if scheduling of a task is shown on time line and if the assignment
uses rate-monotonic discipline, then scheduling sequence repeats
itself after a period of time. this sequence is called a major cycle,
smaller sequence also repeat they are called minor cycles
Jan 8 '08 #19

<so**********@g mail.comwrote in message
news:2e******** *************** ***********@n20 g2000hsh.google groups.com...
On Jan 8, 10:30 am, "Ravishanka r S" <ravishanka...@ in.bosch.com>
wrote:
<sophia.ag...@g mail.comwrote in message
news:3e******** *************** ***********@n22 g2000prh.google groups.com...
Dear all,
The book name is Advanced test in C
and
Embedded System Programming !!!!!!!!!!!

by Ashok .K pathak

some more questions from the book

state whether true or false

1) system can't determine size of the stack before program runs
answer is given as true

2) location of constant string in memory(text area or data area)
may be compiler dependent

answer is given as true
string may be placed in data area of string area depending on
implementation

3)in all cases printf(ptr); and printf("%s",ptr ); will print the same
string,where ptr points to the address of the string

answer is given as false
printf(ptr); fails if ptr contains %
ex:- printf("a%cb"), printf("%s","a% cb"); will print different
strings

4) which of the following is false

(a) a reentrant function may not use variable in a non atomic way
unless they are stored on the stack of the task that called the
function or are other wise the private variable of that task

(b) a reentrant function may not call any other function that are
not reentrant
(c) a reentrant function may not use the hardware in a non atomic
way
(d) a reentrant function may call any other function that are not
reentrant

answer is given as d option

a single copy of code executed by mulltiple tasks and will always
works correctly is called a reentrant code. for example , many task
may call sprintf(),but there is only a single copy of the subroutine
in the system

5)is the following code reentrant?

int j;

void f(void)
{
if(j 10)
{
j = j+1;
printf("%d",j);
}
else
{
j = j-1;
printf("%d",j);
}
}

answer is given as no

violation of rule 1: global variable j is in a fixed loacation in
memory and therefore shared by any tasks that call f.The use of j is
not atomic, because the RTOS might switch tasks between the time it is
tested and the time that it is updated. may violate rule 2 for this
function to reentrant,print f must also be reentrant
6) In a program written in C find the major and minor cycle(rem) ?

main()
{
while(1)
{
proc_w();
proc_x();
proc_w();
proc_y();
proc_w();
proc_x();
proc_w();
proc_z();

}
}
answer is given as

major cycle wxwywxwz
minor cycle wxwz wxwy wx wy wz

if scheduling of a task is shown on time line and if the assignment
uses rate-monotonic discipline, then scheduling sequence repeats
itself after a period of time. this sequence is called a major cycle,
smaller sequence also repeat they are called minor cycles
The answers seem OK AFAIK. Better is to post at comp.embedded for comments
Jan 8 '08 #20

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

Similar topics

0
4107
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for all companies between year 2000-2005 in my website http://www.geocities.com/allinterviewquestion/ So please have a look and make use of it.
0
4602
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
7229
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
4
2514
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for cross-posting. I am trying to build a "checklist", where a user can navigate to an ASP page on the intranet which shows a list of "questions" that the user can check off. I am trying to figure out how to do this so that it is scalable, but I am...
8
7988
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying to catch up again with Python. I am now appearing for Job Interviews these days and I am wondering if anybody of you appeared for a Python Interview. Can you please share the questions you were asked. That will be great help to me.
0
1504
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html C# Interview Questions and Answers 6 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html C# Interview Questions and Answers 5...
1
1626
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html C# Interview Questions and Answers 6 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html C# Interview Questions and Answers 5...
0
4517
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html C# Interview Questions and Answers 6 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html C# Interview Questions and Answers 5...
0
3434
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
2946
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
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
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...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
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
7571
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
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.