C# | Print numbers from 1 to 15 using while loop

C# while loop Example: Here, we are going to learn how to print numbers from 1 to 15 while loop in C# programming language?
Submitted by Pankaj Singh, on December 01, 2018 [Last updated : March 19, 2023]

Here, we have to print the numbers from 1 to 15 using while loop in C#.

C# program to print numbers from 1 to 15 using while loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loop1 {
  class Program {
    static void Main(string[] args) {
      int a;
      
      a = 1;
      while (a <= 15) {
        Console.WriteLine(a);
        a++;
      }
      
      //wait to hit any key to exit the program
      Console.ReadKey();
    }
  }
}

Output

1
2
3
4
5
6
7
8
9
10 
11 
12 
13 
14 
15 

C# Basic Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.