Tuesday, December 17, 2013

Write an algorithm to draw following pattern

        *
      ***
    *****
  *******
*********

Algorithm
STEP 1. rowß0,nß0,cß0,tempß0
STEP 2. print “Enter number of rows”
STEP 3. read n
STEP 4. tempßn
STEP 5. Repeat for row=1,2,3,4……n
Begin
Repeat for c=1, 2, 3……(temp-1)
Begin
print “ ”
End
Repeat for c=1, 2, 3……(2*row-1)
Begin
print “*”
End
          tempßtemp-1
print “\n”
End

No comments:

Post a Comment