Click here to Skip to main content
15,896,278 members

Comments by vikasvds (Top 5 by date)

vikasvds 7-Sep-10 5:53am View    
Reason for my vote of 5
good explaination
vikasvds 16-Jul-10 8:10am View    
Hi,

Sorry to not to paste code written by me.
I am almost able to get it with one loops but i am not liking too many variables and if-else.

i am unable to think of any single straight logic/equation to do the same

it is below here -
#define ROWS 10
int main(void)
{
int i = 0, j = 0, counter = 0, start_shrinking = 0;
for(i = 0; i = ((ROWS/2)-j))
printf("*");
else
printf(" ");

counter++;
}
}
}

output is not exactly * arranged in diamond shape as given below
_____*
____***
___*****
__*******
_*********
__*******
___*****
____***
_____*

i have used underscore instead of spaces since in HTML all spaces were disappeared.
This is not the homework i am curiously doing it.

Thanks very much
vikasvds 16-Jul-10 8:10am View    
Hi,

Sorry to not to paste code written by me.
I am almost able to get it with one loops but i am not liking too many variables and if-else.

i am unable to think of any single straight logic/equation to do the same

it is below here -
#define ROWS 10
int main(void)
{
int i = 0, j = 0, counter = 0, start_shrinking = 0;
for(i = 0; i = ((ROWS/2)-j))
printf("*");
else
printf(" ");

counter++;
}
}
}

output is not exactly * arranged in diamond shape as given below
_____*
____***
___*****
__*******
_*********
__*******
___*****
____***
_____*

i have used underscore instead of spaces since in HTML all spaces were disappeared.
This is not the homework i am curiously doing it.

Thanks very much - vikasvds 1 hour ago
vikasvds 16-Jul-10 6:30am View    
Hi all,

Sorry to not to paste code written by me.
I am almost able to get it with one loops but i am not liking too many variables and if-else.

i am unable to think of any single straight logic/equation to do the same

it is below here -
#define ROWS 10
int main(void)
{
int i = 0, j = 0, counter = 0, start_shrinking = 0;
for(i = 0; i <= ROWS*ROWS; i++)
{
if(i != 0 && i%ROWS == 0)
{
printf("
");
if(j < (((ROWS)/2)-1) && 0 == start_shrinking )
{
j++;
}
else
{
j--;
start_shrinking = 1;
}
counter = 0;
}
else
{
if(counter <= ((ROWS/2)+j) && counter >= ((ROWS/2)-j))
printf("*");
else
printf(" ");

counter++;
}
}
}

output is not exactly * arranged in diamond shape as given below
_____*
____***
___*****
__*******
_*********
__*******
___*****
____***
_____*

i have used underscore instead of spaces since in HTML all spaces were disappeared.
This is not the homework i am curiously doing it.

Thanks very much
vikasvds 3-Jun-10 10:21am View    
Thank you very much!!
Your explanation cleared my doubt.
Thanks again.