A31 Answer


#include <stdio.h>

void starLine( int n )
{
  int j;
  for ( j=0; j<n; j++ )
    putchar('*');
  putchar('\n');
}

int main(int argc, char *argv[])
{
  starLine( 8 );  
  
  system("PAUSE");	
  return 0;
}

Comments: You could also use printf("*") in the above.

If you want to use a command line parameter, do this:

int main(int argc, char *argv[])
{
  int stars=0;
  
  if ( argc >= 2 ) stars = atoi( argv[1] );
  starLine( stars );  
. . .

An odd aspect of this program is that the statement putchar('\n') outputs different characters depending your operating system. On windows systems it prints out "carriage return" followed by "line feed." On Unix systems it prints out a single "line feed" character and on older Apple systems it prints out "carriage return".