תחביר
- קוד: בחר הכל
x++; // increment x by one and returns the old value of x
++x; // increment x by one and returns the new value of x
x-- ; // decrement x by one and returns the old value of x
--x ; // decrement x by one and returns the new value of x
פרמטרים בתחביר:
x - משתנה מסוג מספרים שלמים int או long, אפשר גם unsigned
הסבר לתחביר:
++x
- מקדם את x ב-1 ומחזיר את ערך ה-x לפני הקידוםx++
- מקדם את x ב-1 ומחזיר את ערך ה-x אחרי הקידום--x
- מפחית 1 מ-x ומחזיר את ערך ה-x לפני ההפחתהx--
- מפחית 1 מ-x ומחזיר את ערך ה-x אחרי ההפחתהדוגמה
- קוד: בחר הכל
x = 2;
y = ++x; // x now contains 3, y contains 3
y = x--; // x contains 2 again, y still contains 3
ראו גם:
=+ (הוספה ל...)=- (הפחתה מ...)
פירוט שפת תכנות לסביבת Arduino
עמוד זה הוא תרגום של ++ (increment) / -- (decrement) לפי רישיון Creative Commons Attribution-ShareAlike 3.0.