değişken = değişken [operatör] aritmetik ifade;
değişken [operatör]= aritmetik ifade;
| OPERATÖR | AÇIKLAMA | ÖRNEK | ANLAMI |
| = | atama | x = 8; | x = 8; |
| += | ekleyerek atama | x += 2 | x = x + 2 |
| - = | eksilterek atama | x - = 4 | x = x - 4 |
| *= | çarparak atama | x *= 4 | x = x * 4 |
| /= | bölerek atama | x /= 2 | x = x / 2 |
| %= | bölüp, kalanını atama | x %= 9 | x = x % 9 |
| ++ | bir arttırma | x++ veya ++x | x = x + 1 |
| -- | bir azaltma | x-- veya --x | x = x - 1 |
/* bir arttırma işlemleri */
i++;
++i;
i += 1;
i = i + 1;
/* karmaşık atamalar */
f *= i; // f = f * i; anlamında
f *= i+1; // f = f * (i+1); anlamında
z /= 1 + x; // z = z / (1+x); anlamında
a = 5; // a = 5
b = a++; // a = 6 ve b = 5
c = ++a; // a = 7 ve c = 7
/* 03prg01.c: Aritmetik ve atama operatorlerinin kullanimi
*/
#include <stdio.h>
main()
{
int x, y; /* yerel değişkenlerin bildirimi */
x = 1; /* x in başlangıç degeri */
y = 3; /* y nin başlangıç degeri */
printf(" x = %d ve y = %d, olarak veriliyor.\n", x,
y);
x = x + y; printf("x <- x + y atamasının sonucunda x=%d dir\n",
x);
x = 1; /* x e tekrar 1 degeri ataniyor */
x += y;
printf("x += y atamasinin sonucunda x=%d dir\n", x);
return 0;
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?