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 ? 23 2768
On Mon, 07 Jan 2008 08:50:08 -0800, sophia.agnes wrote:
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
It's possible that it used to be right in the previous version of C -- I
am not sure about that -- but now, this is wrong. Concatenation of a
narrow and a wide string literal is allowed, and produces one single wide
string.
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
This is implementation-specific; some implementations may always reserve
memory for objects with block scope, but there is no requirement for them
to do so.
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
I don't understand these statements. When x is an object, *&x is
completely equivalent to x, and when x is a pointer, &*x is equivalent to
x, except that it is not an lvalue.
5)which operation require more memory access
(a) branch
(b) conditional code test
(c) shift register right /* what is this ?*/
(d) all are same
This is, again, specific to the implementation.
In article <88************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>I can't think of any operator that /requires/ an lvalue operand.
++
-- Richard
--
:wq
Richard Tobin said:
In article <88************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>>I can't think of any operator that /requires/ an lvalue operand.
++
Well, there ya go - it shows that I didn't think very hard...
Of course, it won't take just any old lvalue. It requires a modifiable
lvalue that is not a structure or union.
--
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
Richard Heathfield wrote:
Richard Tobin said:
>In article <88************ *************** ***@bt.com>, Richard Heathfield <rj*@see.sig.in validwrote:
>>I can't think of any operator that /requires/ an lvalue operand.
++
Well, there ya go - it shows that I didn't think very hard...
Of course, it won't take just any old lvalue. It requires a modifiable
lvalue that is not a structure or union.
unless it is overloaded...
:-)
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32 so**********@gm ail.com wrote:
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
The answer is correct, but the explanation seems at best
"confused." In particular, `*n' is not an lvalue, but an
error requiring a diagnostic. Also `(p + 1)' is not always
an rvalue (consider `void *p'), and `*(p + 1)' is not always
an lvalue (consider `int *p = &n').
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
Certainly (b) is also false.
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
All four answers are false (or perhaps "undecidabl e") from
the point of view of the C language, although one or more may
be true of particular implementations of C.
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
I don't know, because I cannot make sense of either s1 or s2.
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
As in #3, the question is meaningless as far as the C
language goes, but may have meaning for some implementations .
well what do you folks think of all this stuff ?
Not much. I've seen worse, but I've seen much better.
-- Er*********@sun .com
Richard Heathfield wrote:
so**********@gm ail.com said:
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
Without actually doing an exhaustive study, I'm pretty sure this is false.
a=3
....
& can take the name of a function, which is far from being an lvalue! I
can't think of any operator that /requires/ an lvalue operand.
The increment, decrement, and assignment operators all require an
lvalue operands.
....
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."
On Jan 7, 10:07 pm, Harald van D©¦k <true...@gmail. comwrote:
On Mon, 07 Jan 2008 08:50:08 -0800, sophia.agnes wrote:
>
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
I don't understand these statements. When x is an object, *&x is
completely equivalent to x, and when x is a pointer, &*x is equivalent to
x, except that it is not an lvalue.
answer is given as follows:-
consider the following program
main()
{
char x[] = "abcde";
printf("%d %d", x+3,&*x+3);
printf("%d %d", x+3,*&(x + 3));
}
x[i] = (*(x + i));
&x[i] = &(*(x+i));
C precedence rule evaluate & and * from right to left, so we can
remove the outer parenthesis i.e
&x[i] = &*(x + i) reduced to &x[i] = (x+i)
In article <88************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>... I can't think of any operator that /requires/ an lvalue operand.
All of the assignment operators (e.g., +=), and the pre- and
post-fix ++ and -- operators, require at least one lvalue operand.
(As you note, unary & requires an lvalue only when it is applied
to objects, since function designators are not lvalues.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
In article <88************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>& is one such operator int n; *n is lvalue
Close. n is an object. *n is illegal.
>&n is rvalue
& can take the name of a function, which is far from being an lvalue!
Though you are of course right about that, the answer does come close
to the *idea* of lvalues. The idea of an lvalue is that it's
something on the left-hand side of an assignment - something that can
be assigned to - a place rather than a value. The ability to take the
address of something clearly implies that it is a place.
The fact that you can't say
int foo(void) {...}
int bar(void) {...}
....
foo = bar;
is not really any different from the situation with
int foo[10];
int bar[10];
....
foo = bar;
so there's no real reason why function names should not be considered
lvalues just as array names are.
-- Richard
--
:wq This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
|
by: connectrajesh |
last post by:
INTERVIEWINFO.NET
http://www.interviewinfo.net
FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES
NO ADVERTISEMENT
|
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
|
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...
|
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.
| |
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...
|
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...
|
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...
|
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
|
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
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |