471,887 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

+= plus equal sign

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
2 68581
JosAH
11,448 Expert 8TB
+= 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
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.

Similar topics

1 post views Thread by johndesp | last post: by
11 posts views Thread by =?ISO-8859-1?Q?Konrad_M=FChler?= | last post: by
5 posts views Thread by souporpower | last post: by
1 post views Thread by =?Utf-8?B?Sm9zdWZm?= | last post: by
reply views Thread by YellowAndGreen | last post: by

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.