this code will enter numbers and print sum them between 1 to 10 // the problem is : it sum all the nummbers except the first number i entered
example : if I enter 5 3 2 1 will print sum(3+2+1) = 6. will not sum 5 with numbers
example : if I enter 5 3 2 1 will print sum(3+2+1) = 6. will not sum 5 with numbers
C#:
int a = int.Parse(Console.ReadLine());
int sum = 0;
while (a < 10 && a > 0)
{
a = int.Parse(Console.ReadLine());
if (a < 10 && a > 0)
{
sum = sum + a;
Console.WriteLine(sum);
}
else
{
Console.WriteLine("No");
Console.WriteLine(sum);
}
}
Last edited by a moderator: