[Help Needed] Converting C++ program into Mathematica Function

*To*: mathgroup at smc.vnet.net*Subject*: [mg71156] [Help Needed] Converting C++ program into Mathematica Function*From*: a1b2c3d4 <ms-z- at hotmail.com>*Date*: Thu, 9 Nov 2006 03:39:14 -0500 (EST)

i've tried for quite some time but am still stuck at it. the C++ program is as follows: #include<stdio.h> main() { int Current_line, Num_Of_Star, Num_Space; int N, Num_Star_Current_line,m; printf("\n How many Lines:"); scanf("%d",&N); for(Current_line = 1; Current_line <= N; Current_line=Current_line+1) { Num_Space = N -Current_line; for(m =1; m <= Num_Space;m = m+1) { printf(" "); } Num_Star_Current_line = Current_line * 2 -1; for(Num_Of_Star =1; Num_Of_Star <= Num_Star_Current_line; Num_Of_Star= Num_Of_Star + 1) { printf("*"); } printf("\n"); } } The Mathematica function i've tried to write is as follows: printstars := Block[{n, i, space1, star1}, n = Input["Enter the number of lines:"]; For[i = 1, i Â¡<= n, i++, (space1 = n - i; star1 = i 2 - 1); Do[Print[" "], {space1}]; Do[Print["*"], {star1}]; ]] However, Mathematica gives output for each * on a new line. I've tried to use the function "StringJoin" but still can't seem to make it work. Anyone has suggestions? Your help will be greatly appreciated.

**Follow-Ups**:**Re: [Help Needed] Converting C++ program into Mathematica Function***From:*"Chris Chiasson" <chris@chiasson.name>

**Re: [Help Needed] Converting C++ program into Mathematica Function***From:*Sseziwa Mukasa <mukasa@jeol.com>