473,670 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,ass oivity)
thanks in advance.

Nov 15 '05 #1
7 1841

pw********@yaho o.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,ass oivity)
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********@yaho o.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********@yaho o.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**********@ya hoo.co.in writes:
pw********@yaho o.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,ass oivity)
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_Keit h) 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**********@ya hoo.co.in writes:
pw********@yaho o.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_Keit h) 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********@yaho o.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,ass oivity)
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
6370
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 describe if applied to a sequence of length items. It returns a tuple of three integers; respectively these are the /start/ and /stop/ indices and the /step/ or stride length of the slice. Missing or out-of-bounds indices are handled in a manner...
13
12307
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 below the decimal variable from the arraylist. Thanks ever so much in advance
4
2191
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
8725
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 DataList exposes and the result is always null (I've determined the OnItemDataBound event will not find the footer controls). I understand that I have to navigate the datalist object tree, but I feel like it is a guessing game and am hesitant to do it...
67
7684
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 4/30/06 I am looking for suggestions on how to find the date ranges where there were no transactions.
5
2573
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 it returns the iterator to the last element in the range, not to the last element in the container, to the last element in the range. That being said, how can we tell if find() has been successful in finding the element we need? Its easy when we...
8
8645
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
5269
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 working. But before I get to the remove, I need to get my find method working. Basically, I am trying to get a "find" method working that will search for a giving int value, and return the node with that value. I have designed my current find with the...
1
2996
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: =+'H:\QC\2007\Quarter 1\EC\Risk Measures'!F14 and paste value it. I'm using Ms. Excel 2000. Procedures: 1) Choose the Source_Directory and Source_Name
5
4538
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 that comes with your browser window, IE; click edit, then find on this page, which brings up the search box. I know that JavaScript can do this. I tried to insert JavaScript to my .cfm page. It doesn't work. Any help will be appreciated. Here...
0
8388
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
8907
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
8663
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
7423
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
6218
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
5687
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();...
1
2804
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
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1799
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.