You add by using the +=
operator:
for (i = 1; i <= n; i++)
total += i;
cout << total;
Note this is short for total = total + i
.
3
solved for-Loop to add integers [closed]
You add by using the +=
operator:
for (i = 1; i <= n; i++)
total += i;
cout << total;
Note this is short for total = total + i
.
3
solved for-Loop to add integers [closed]