and adds them to the variable sum
im supposed to get 100500 but with this code im getting 1000
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int lowerBounds = 1;
int upperBounds = 1000;
int sum = 0;
for (int i = lowerBounds; i <= upperBounds; i++)
{
if (i % 5 == 0)
sum += 5;
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int lowerBounds = 1;
int upperBounds = 1000;
int sum = 0;
for (int i = lowerBounds; i <= upperBounds; i++)
{
if (i % 5 == 0)
sum += 5;
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
John IwaszPosted Dec 17, 2018, 1:40 PM