By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

+= plus equal sign

P: 5
What does += mean?
Expand|Select|Wrap|Line Numbers
  1. int julian_day( int month, int day, int year )
  2. {
  3.   int jday = 0;
  4.   for (int m=1; m<month; ++m )
  5.     { 
  6.       jday += DaysInMonth[m];
  7.       if ( m == 2 && is_leap_year(year))
  8.           ++jday;  // February 29th
  9.     }
  10.   jday += day;
  11.   return jday;
  12. }
  13.  
Thanks a lot
Jul 28 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
+= is the 'add assignment operator; e.g.

Expand|Select|Wrap|Line Numbers
  1. int foo= 1;
  2.  
  3. foo+= 41; // foo has value 42 now
  4.  
You can do the same with most of the other binary operators; && and || can't
be used like that.

kind regards,

Jos
Jul 28 '07 #2

P: 2
eg a+=1 means a=a+1 such an operation can be used for all arithmetic operations
Jul 28 '07 #3

Post your reply

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