/* triangle.c program */
#include <stdio.h>
#include <stdlib.h>
int main()
{
int row_width = 1;
int rows = 0, x = 0, y = 0, a = 0;
int num_rows;
printf("%s", "Please enter the number of rows\n");
printf("Then press enter: ");
scanf("%d", &rows);
for(a = 0; a < rows; a++)
{
for( y = num_rows; y > 0; y--)
{
printf("%s", " ");
}
num_rows --;
for( x = 0; x < row_width; x++)
{
printf("%s", "*");
}
printf("\n");
row_width += 2;
}
system("PAUSE");
return 0;
}
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 07 October 2010 - 10:48 AM

New Topic/Question
Reply




MultiQuote










|