ഓരോന്നായി കൂട്ടി ആകെ തുക കാണുക
പൂജ്യത്തിൽ നിന്ന് ആരംഭിച്ച് ഓരോ മൂല്യവും നിങ്ങൾ എത്തുമ്പോൾ കൂട്ടിച്ചേർക്കുക.
ഒരു ലളിതമായ ഉദാഹരണം
തുടക്കത്തിൽ2 + 4
ഫലം6
using System;
int total = 0;
total += 2;
total += 4;
Console.WriteLine(total);
6
പരസ്യങ്ങൾ
നിത്യജീവിതത്തിലെ ഉദാഹരണങ്ങൾ
മൂന്ന് ക്ലാസുകൾ 5, 2, 4 പുസ്തകങ്ങൾ സംഭാവന ചെയ്യുന്നു. ലൈബ്രറിക്ക് എത്ര പുസ്തകങ്ങൾ ഷെൽഫുകളിൽ വെക്കാൻ കഴിയും?
തുടക്കത്തിൽ5 + 2 + 4
ഫലം11
using System;
int[] books = new int[] { 5, 2, 4 };
int total = 0;
int i = 0;
while (i < 3) {
total += books[i];
i += 1;
}
Console.WriteLine(total);
11
ഉദാഹരണം റൺ ചെയ്യൂ
dotnet new console --output Lesson
cp Program.cs Lesson/Program.cs
dotnet run --project Lesson