Tuesday, December 17, 2013

Draw a Flowchart to implement following pattern

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



Draw a Flowchart to implement following pattern

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



Write an algorithm to draw following pattern

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

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

tempßtemp-1
print “\n”

End

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

Write an algorithm to draw following pattern

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

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

End

Thursday, October 10, 2013

ALGORITHM TO FIND SUM OF THE SERIES 1*5 - 2*7 + 3*9 - 4*11 ... UPTO N TERMS


STEP 1.      I <-- 1, J=5, Sum <-- 0, N <-- 0, Sign=1
STEP 2.      Read N
STEP 3.      While (I <= N)
        Begin
             Sum <-- Sum+  Sign*(I * J)
         J <-- J + 2
      I <-- I + 1
      Sign= Sign * (-1)
             End
STEP 4.      Print Sum

ALGORITHM TO FIND SUM OF THE SERIES 2+5+8+11...UPTO N TERMS


STEP 1.      I <-- 0, J=2, Sum <-- 0, N <-- 0
STEP 2.      Read N
STEP 3.      While (I <= N-1)
        Begin
             Sum <-- Sum+ J
         J <-- J + 3
      I <-- I + 1
             End
STEP 4.      Print Sum