WHy doesnt this simple code work? starts at 14 why??

When I compile this, it starts at 14. But why Shouldn't it start at 1 Like, it would write the number 1 for 25 times, then the number 2 for 25 times, etc till number 25 for 25 times.
I don't understand what is wrong with this code.
Thank you

using System;
namespace ConsoleApplication3
{
class Program
{
public static int index,op;
static void Main(string[] args)
{
for (index=1; index < 26; index++)
{
for (op = 1; op < 26; op++)
{
Console.WriteLine(index);
}
}
Console.ReadLine();
}
}
}




Answer this question

WHy doesnt this simple code work? starts at 14 why??

  • Steve - B3

    Its correct. It writing so much to the console window you can't scroll back up to see the 1-13.

    Do this and you will see

    using System;
    namespace ConsoleApplication3
    {
    class Program
    {
    public static int index,op;
    static void Main(string[] args)
    {
    for (index=1; index < 26; index++)
    {
    for (op = 1; op < 26; op++)
    {
    Console.Write(index);
    }

    Console.WriteLine("");
    }
    Console.ReadLine();
    }
    }
    }



  • ga2006

    there is nothing wrong with your code, but the console's screen limit.

    console can't display more then 300 lines(default), and it will scroll the earlier message out of the window.

    just have a pause before you may lost some message or enlage the max lines limit.



  • WHy doesnt this simple code work? starts at 14 why??