Odd numbers descending Learn programming C#

Lesson:

Flow Control


Exercise:

Odd numbers descending


Objetive:

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


Code:

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

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

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.