hello,
Can any one tell me how to print the patter

*
***
 *
for n =1
 **
****
****
 **
for n = 2
 ***
*****
*****
*****
 ***
for n = 3

the code i am having is

for(i=0;i<=n;i++)
{
   for(j=1;j<n-i;j++)
     putchar(' ');
   for(k=0;k<=i;k++)
    printf('* ');
  putchar('\n');
}

what will be the condition so that i will get that pattern
thanking you

You're over-engineering the solution. It's really nothing more than this:

print ' '
print n '*'

for i = 0 to n do
  print n + 2 '*'
loop

print ' '
print n '*'

You're over-engineering the solution. It's really nothing more than this:

print ' '
print n '*'

for i = 0 to n do
  print n + 2 '*'
loop

print ' '
print n '*'

but how do i convert this code in to C code??

>but how do i convert this code in to C code??

print ' ' ---> How would you display a space in C?
print n '*' ---> How would you display a * as many times as n is equals to?

for i = 0 to n do
print n + 2 '*' ---> How would you display in C a * n times plus 2 more?
loop ---> How would you loop in C from 0 to n?

print ' ' ---> How would you display a space in C?
print n '*' ---> How would you display a * as many times as n is equals to?

>but how do i convert this code in to C code??

print ' ' ---> How would you display a space in C?
print n '*' ---> How would you display a * as many times as n is equals to?

for i = 0 to n do
print n + 2 '*' ---> How would you display in C a * n times plus 2 more?
loop ---> How would you loop in C from 0 to n?

print ' ' ---> How would you display a space in C?
print n '*' ---> How would you display a * as many times as n is equals to?

Okay I apologize .....

>but how do i convert this code in to C code??
There's a reason I didn't give you C code. ;)

This article has been dead for over six months. Start a new discussion instead.