473,668 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the result of a[++i] = i ; ?

1 New Member
if a[3]={-1,-2,-3};
i=0;
what a[++i] = i work?
Apr 17 '13 #1
3 1501
vijay6
158 New Member
Hey mxy0226,

The value of 'i' (1 - One) will assign to a[1].

Workflow:

1) This statement evaluate from right to left.

2) In the right hand side, no changes. The value of 'i' remain as it is (i=0).

3) In the left hand side, first '++i' statement will execute. i.e., The value of 'i' incremented by 1. Now 'i' is 1.

4) Finally the assignment statement execute. a[1] = 1 (Because now 'i' value is 1).

5) After that statement (a[++i] = i) the array 'a' will look like this a[3] = {-1, 1, -3};
Apr 17 '13 #2
VanessaMeacham
31 New Member
HI ! this operator perform right to left so vijay6's answer is right. it also overloads.
Apr 17 '13 #3
Banfa
9,065 Recognized Expert Moderator Expert
Actually the behaviour is undefined because you are accessing a variable (i) more than once between sequence points where one of those accesses modifies the value of the variable.

You do not know what order the 2 sub-expressions of the = operator are evaluated in, it is not specified in the standard.
Apr 17 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

303
17596
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
19
3615
by: Arthur T. Murray | last post by:
A C++ AI Weblog for implementing artificial intelligence is at http://mentifex.virtualentity.com/cpp.html -- with C++ source. Arthur T. Murray -- http://doi.acm.org/10.1145/307824.307853 -- ACM SIGPLAN Notices; http://www.sl4.org/archive/0205/3829.html -- comments by Dr. B.G. http://www.amazon.com/exec/obidos/ASIN/0595654371/ -- AI textbook http://www.kurzweilai.net/mindx/profile.php?id=26 - Mind-eXchange
1
1731
by: david.goodyear | last post by:
Hi, I have a query that gives me almost the results I want, which is SELECT ai.entry_date as CallTime, ai.agent_login as AgentsLogin, ai.campaign as MarketingCampaign, ai.agent_input2 as ProductsSold, ai.first_name as Cust_FirstName, ai.last_name as Cust_LastName,
10
8514
by: Simon Brooke | last post by:
I'm struggling to understand what 'exclude-result-prefixes' does and is for; the language of the standard http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#literal-result-element is not exactly easy to follow. What I assumed it was supposed to do is mark specific prefixes as not to be printed in the generated document, but that does not work with any of the XSL tools I'm currently working with (Xalan 1.2.2 and 2.7.0, xsltproc...
2
1627
by: nani | last post by:
Hi friends I am creating one web application in that i take one hyperlink control.when i click hyperlink control.how to split the page in two parts and display the result in that secound part If the result is not there again in orginal format How to create it plz tell
2
1469
by: Robert | last post by:
dear sir: I have read the c++ primer plus 5 book, and do the chapter 12 programming exercises question 5, but the average_wait have negative result. I don't understand why? here is the code, thank you anyone replay me.:) /************************* customer.h *************************/ #ifndef CUSTOMER_H_ #define CUSTOMER_H_
7
4610
bugboy
by: bugboy | last post by:
Hi, I'm just learning PHP. I want to redirect the user, after hitting submit, either to the same page displaying the results (as it is now) or if no results are found then send them to a new page passing on the original form data there instead. Below is a simplified version of what i'm trying to do. The user sumits a word. If it's in the DB then the word is listed below the reset form. What i need is to redirect to a new page "newword.php" if...
33
5686
by: James H. Newman | last post by:
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ;
22
1596
by: Curious | last post by:
I'm developing a proprietary system in C#.NET. The assembly is in a folder accessible by outside people. Since it's critical that others don't know what it's about and how it's implemented, I want to know what information anyone can get by examining the assembly.
4
1903
by: donthomasino | last post by:
#include <iostream> #include <queue> using namespace std; void main() { int encode = {3,1,1,1,3,1,1,1}; queue<char>myMagicWord; myMagicWord.push('c'); myMagicWord.push('o'); myMagicWord.push('n');
0
8797
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
8583
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,...
1
6209
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
5681
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
4205
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
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2791
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
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
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.