Answered # help for this

Auraomega 2 Discussion Starter jemz -1 Auraomega 2 Discussion Starter jemz -1 Adak 419 Discussion Starter jemz -1 Discussion Starter jemz -1 Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...

0

hello can you help me how can i print asterisk to form triangle like this

```
*
***
*****
*******
```

here is my code

```
int main()
{
for(i=0;i<10;i++)
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
getch()
return 0;
}
```

please help me hoping for your positive responds...thank you in advance...

*Edited 6 Years Ago by jemz*: n/a

0

You're not going to call your new line with that for loop.

```
for(i=0;i<10;i++)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
```

Will now give the output:

*

**

***

****

...

So you now need to change the logic to add some spaces to make your * centre. I'll leave that one with you, once you have some updated code if you need any more help post back.

0

You're not going to call your new line with that for loop.

`for(i=0;i<10;i++) { for(j=0;j<i;j++) { printf("*"); } printf("\n"); }`

Will now give the output:

So you now need to change the logic to add some spaces to make your * centre. I'll leave that one with you, once you have some updated code if you need any more help post back.

hello sir here's my updated code i just added "\t" so that i can center my * ..sir what should i do now do i need to put another forloop..please help me sir hoping for your positive responds..

```
for(i=0;i<10;i++)
{
printf("\t");
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
```

0

As I said, you need to add some formatting to cnetralise the * in each row. Until you have some code to show how you've attempted that I can't really help you.

0

hello sir,

can you give me snippet code for formmatting,i don't have idea on this sir...thank you in advance hoping for your positive responds...

0

To find the center column for the first *, you can use either the number of rows in the "tree", or the number of *s, in the bottom row.

So if the bottom row has 7 *s, then 7/2 equals 3. So you should have 3 spaces before the * on the first row. You can use a for loop (outer one), to code this:

```
//handles the outer row configuration
for(numstars=1;numstars<=botmRow;numstars+=2) {
numspaces = (botmRow - numstars)/2;
//handles the spaces before the stars
for(i=0;i<numspaces;i++)
print one space here
//prints out the star/s
for(i=0;i<numstars;i++)
print out star/s here
}
```

So the top row could be seen as:

`spc spc spc * spc spc spc`

because the top row will always have just ONE star. So all the other char's will have to be spaces. :)

Now for each row, the number of stars increases by 2, and that means the number of spaces on each side of the stars, will decrease by 1 (since there are two sides, and 2 * 1 = 2.

imo you don't want to use tabs for this assignment.

0

To find the center column for the first *, you can use either the number of rows in the "tree", or the number of *s, in the bottom row.

So if the bottom row has 7 *s, then 7/2 equals 3. So you should have 3 spaces before the * on the first row. You can use a for loop (outer one), to code this:

`//handles the outer row configuration for(numstars=1;numstars<=botmRow;numstars+=2) { numspaces = (botmRow - numstars)/2; //handles the spaces before the stars for(i=0;i<numspaces;i++) print one space here //prints out the star/s for(i=0;i<numstars;i++) print out star/s here }`

So the top row could be seen as:

`spc spc spc * spc spc spc`

because the top row will always have just ONE star. So all the other char's will have to be spaces. :)

Now for each row, the number of stars increases by 2, and that means the number of spaces on each side of the stars, will decrease by 1 (since there are two sides, and 2 * 1 = 2.

imo you don't want to use tabs for this assignment.

hello sir thank you for helping me sir it works....more power to you......

0

To find the center column for the first *, you can use either the number of rows in the "tree", or the number of *s, in the bottom row.

So if the bottom row has 7 *s, then 7/2 equals 3. So you should have 3 spaces before the * on the first row. You can use a for loop (outer one), to code this:

`//handles the outer row configuration for(numstars=1;numstars<=botmRow;numstars+=2) { numspaces = (botmRow - numstars)/2; //handles the spaces before the stars for(i=0;i<numspaces;i++) print one space here //prints out the star/s for(i=0;i<numstars;i++) print out star/s here }`

So the top row could be seen as:

`spc spc spc * spc spc spc`

because the top row will always have just ONE star. So all the other char's will have to be spaces. :)

Now for each row, the number of stars increases by 2, and that means the number of spaces on each side of the stars, will decrease by 1 (since there are two sides, and 2 * 1 = 2.

imo you don't want to use tabs for this assignment.

hello sir thank you for helping me...it works...more power to you...

This question has already been answered. Start a new discussion instead.

Recommended Articles

I don’t want at this stage work on a big separate project as I've already got plenty ...