FLOYD'S TRIANGLE

2 posts, 0 answers
  1. herchel
    herchel avatar
    1 posts
    Member since:
    Aug 2011

    Posted 16 Aug 2011 Link to this post

    #include <stdio.h>
    #include <conio.h>

    main( )
    {
    int i, j, k = 1;
    clrscr( );

    for( i = 1; k <= 15; ++i )
    {
    for( j = 1; j <= i; ++j )
    printf( "%d ", k++ );
    printf( "\n\n" );
    }

    getch( );
    return 0;
    }

    CAN PLEASE someone convert those codes into c++ codes .

  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 17 Aug 2011 Link to this post

    Hello Herchel,

    I believe you posted your question in a wrong forum. Nevertheless, this code will look the same in all C-derived languages - no major conversion will be needed.
    For C++ you can replace the printf with cout, for C# you can replace printf with Console.WriteLine but the rest will be pretty much the same.

    C#
    static void Main(string[] args)
    {
        int i, j, k = 1;
        Console.Clear();
        for (i = 1; k <= 15; ++i)
        {
            for (j = 1; j <= i; ++j)
            {
                Console.WriteLine("{0:d}", k++);
            }
            Console.WriteLine();
            Console.ReadKey(true);
        }
    }

    Regards,
    Daniel
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top