Home
Aptitude
Categories


Home » C# programs » C# basic programs

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

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

Program:

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 





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.