473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

find value

hi everyone out there
can anyone give me the value of a(wn executed saperatly)
initially a=5
a+=(a++)+(++a)
a-=(--a)-(a--)
support ur answers with reasons (precedence,assoivity)
thanks in advance.

Nov 15 '05 #1
7 1821

pw********@yahoo.co.in wrote:
hi everyone out there
can anyone give me the value of a(wn executed saperatly)
initially a=5
a+=(a++)+(++a)
a-=(--a)-(a--)
support ur answers with reasons (precedence,assoivity)
thanks in advance.


You are trying to modify the variable "a" more than once without an
intervening sequence point. The behaviour is undefined and may produce
different values of variable
"a" on different implementations.
For more details, search for "sequence points" in this
newsgroup. You will find enough information.

Its always better not to use such expressions if there
are other better/simpler ways of doing the same.

Nov 15 '05 #2

give me the values saperately(2 values of a)

Nov 15 '05 #3

pw********@yahoo.co.in wrote:
give me the values saperately(2 values of a)

42 & 42. But there may be slight variations depending on the
temperature.

0. Learn some basic rules when you are going to post to a
newsgroup. There is enough information in this newsgroup only,
so search.
1. Check the FAQ. 3.2 should be of particular interest to you.
That said, read the whole of section 3, and if you still have some
time, the whole FAQ.

Nov 15 '05 #4

pw********@yahoo.co.in wrote:
give me the values saperately(2 values of a)

It could be anything 17,18 or 19.

a+= a++ + ++a;

Its not guaranteed that which of subexpression a++ or
++a would be evaluated first. Suppose, that some implementation
does a++ first and then ++a. Taking initial value of a=5,

a++ would take a initial value 5 before incrementing. Now,
since there is no sequence point after a++, its not guaranteed
if the location where "a" is stored has the updated value or not.
So,while evaluating ++a, "a" could be either 5 or it could be 6. Also,
when ++a is evaluated, again there's
is no guarantee if location "a" has been updated with the
incremented value. So, when you add (a++ + ++a) to a, you
are not sure what would be the value of a. It could be 5,6 or
even 7.
The only sequence point in this statement is "semicolon" after
which all the side effects due to this statement would have
been settled.

Nov 15 '05 #5
ju**********@yahoo.co.in writes:
pw********@yahoo.co.in wrote:
hi everyone out there
can anyone give me the value of a(wn executed saperatly)
initially a=5
a+=(a++)+(++a)
a-=(--a)-(a--)
support ur answers with reasons (precedence,assoivity)
thanks in advance.


You are trying to modify the variable "a" more than once without an
intervening sequence point. The behaviour is undefined and may produce
different values of variable
"a" on different implementations.
For more details, search for "sequence points" in this
newsgroup. You will find enough information.

Its always better not to use such expressions if there
are other better/simpler ways of doing the same.


It's always better not to use such expressions.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #6
ju**********@yahoo.co.in writes:
pw********@yahoo.co.in wrote:
give me the values saperately(2 values of a)

It could be anything 17,18 or 19.

a+= a++ + ++a;

Its not guaranteed that which of subexpression a++ or
++a would be evaluated first. Suppose, that some implementation
does a++ first and then ++a. Taking initial value of a=5,

a++ would take a initial value 5 before incrementing. Now,
since there is no sequence point after a++, its not guaranteed
if the location where "a" is stored has the updated value or not.
So,while evaluating ++a, "a" could be either 5 or it could be 6. Also,
when ++a is evaluated, again there's
is no guarantee if location "a" has been updated with the
incremented value. So, when you add (a++ + ++a) to a, you
are not sure what would be the value of a. It could be 5,6 or
even 7.
The only sequence point in this statement is "semicolon" after
which all the side effects due to this statement would have
been settled.


Sorry, but that's nonsense. Modifying an object twice between
sequence points invokes undefined behavior. That doesn't mean that
the expression can evaluated in any of several orders; it means the
behavior is undefined. The result can be 5, 6, 7, 42, sqrt(-1), a
week from next Wednesday, dental floss, or the third plxnrfq on the
left.

Most of these are unlikely in real life, of course, but you really can
get results that are inconsistent with any order of evaluation.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #7
pw********@yahoo.co.in wrote:
give me the values saperately(2 values of a)
Try actually reading the archives for the group. junky_fellow was
correct that you will find all the information you need if you search
for "sequence points" on this group.

Also, even when using Google provide context otherwise people often will
have no idea what you are responding to. Again, if you read the group
you will find lost of posts telling you have to do this.

Before you post in ANY group, read the FAQ and a weeks worth of postings
to find out what the group is about. You question is also answered in
the FAQ as much as it can be sensibly answered.

Your post which junky_fellow answered was:
hi everyone out there
can anyone give me the value of a(wn executed saperatly)
initially a=5
a+=(a++)+(++a)
a-=(--a)-(a--)
support ur answers with reasons (precedence,assoivity)
thanks in advance.


The answer is:
When the first statement is executed a daemon flies out of your nose.
The preceded is an ancient post in this group which you can find by
searching for nasal daemons in the group and selecting the earliest posts.
When the second statement is executed the daemon will put a stake
through your heart. No precedent is needed because nasal daemons can do
anything they feel like doing (and anything they don't feel like doing)
at any time.

In other words, anything can happen because, as you were told, the
behaviour is undefined.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #8

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

Similar topics

108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
13
by: mike | last post by:
I have ListArray with number in Eg: 1, 1.456, 2.43, 4, 6.78 next i have a decimal variable containing one number EG: 1.786 Could someone please tell me how i find the "closest match" number...
4
by: Arjen | last post by:
Hi, I need to add this inside an array: 1 3 2 4 3 2 4 5 5 1 I think of using this:
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
5
by: Draw | last post by:
Hi All, Just a thought, about the find() algorithm in the C++ STL. I read that the find algorithm can take a range of iterators. If it does not find the element it is looking for in that range...
8
by: brekehan | last post by:
If I have a class MyClass { ...bunch o data and methods int x; }; and a stl container of MyClass objects Is there a way to use std::find to get all the elements whose member x
5
gekko3558
by: gekko3558 | last post by:
I am writing a simple binary search tree (nodes are int nodes) with a BSTNode class and a BST class. I have followed the instructions from my C++ book, and now I am trying to get a remove method...
1
by: qiong | last post by:
Dear friends, Good evening, I have some problems with finding keyword ":\" for each cell. My objective is to find that keyword in each cell in each worksheet which represent the link. Eg:...
5
by: YaoBao | last post by:
Is any ColdFusion script I can put on my webpage that will create a search bar so people can type keywords to match it on the current page in my website? It will be exactly like the finder search bar...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

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.