C# For Loop with examples
In this C# program, we will see For Loop with examples.
C# For Loop with examples Code:
private static void Main(string[] args)
{
Console.Write("Enter a number between 1-10 : ");
int input = int.Parse(Console.ReadLine());
if (input <= 10 && input > 1)
{
for (int i = 1; i <= input; i++)
{
Console.Write(i.ToString() + ",");
}
}
else
{
Console.Write("Invalid number entered.");
}
Console.ReadLine();
}
C# For Loop with examples Output: