for (int i = 100; i <= 200; i++) if (i % 7 == 0) sum+= i;
class Program1 { private int number = 100; private int sum = 0; public void Generate() { for (; number < 200; number++) { //first check if number is divisible by 7 if (number % 7 == 0) { sum = sum + number; } } Console.WriteLine("Total: {0}", sum); } }
for
if
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)