top of page
Admin

Simple for loop in C#

To write all the number from 0 to 10


for (int i = 1; i <= 10; i++)
{
    Console.Write($"{i} ");
}
output:
1 2 3 4 5 6 7 8 9 10 

To write all the letter of a text


Console.WriteLine("input a text :");
string text = Console.ReadLine();
for (int i = 0; i < text.Length; i++)
{
    Console.Write($"{text[i]} ");
}

1 view0 comments

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page