Hello Basia. Was your attempt at the code something like my effort?
With a variety of expressions in the for loops, I came up with this:
Code:
#include<stdio.h>
#define MAX 10 /*The maximum number of chars in a line*/
int main(void)
{
int i, j;
for(i=0; i<MAX; i++)
{
for(j=i+1; j>0; j--)
printf("%c",'*');
printf("%c",'\n');
}
printf("%c",'\n');
for(i=MAX; i>0; i--)
{
for(j=i; j>0; j--)
printf("%c",'*');
printf("%c",'\n');
}
printf("%c",'\n');
for(i=0; i<MAX; i++)
{
for(j=MAX-i-1; j>0; j--)
printf("%c",' ');
for(j=i+1; j>0; j--)
printf("%c",'*');
printf("%c",'\n');
}
printf("%c",'\n');
for(i=0; i<MAX; i++)
{
for(j=i; j>0; j--)
printf("%c",' ');
for(j=MAX-i; j>0; j--)
printf("%c",'*');
printf("%c",'\n');
}
return 0;
}
This will produce the four possible patterns.
And good evening to Prelude... (It's 1am in the UK...)
Cheers from Badger!