This is a migrated thread and some comments may be shown as answers.

FLOYD'S TRIANGLE

1 Answer 40 Views
Code Converter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
herchel
Top achievements
Rank 1
herchel asked on 16 Aug 2011, 03:06 PM
#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 .

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Aug 2011, 06:37 AM
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.

Tags
Code Converter
Asked by
herchel
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or