Programming Course in C# ¡Free!

Odd numbers, descending

 Friday, April 05, 2013 published by Exercises C#
Proposed exercise

Create a program to display on the screen the odd numbers from 15 to 7 (downwards), using "while".

Output



Solution


using System;
public class OddNumbers
{
public static void Main()
{
int n = 15;

while (n >= 7)
{
Console.WriteLine(n);
n -= 2;
}
}
}