Wednesday, October 9, 2013

ALGORITHM TO PRINT FIRST N NUMBERS STARTING FROM 0



Method 1
STEP 1.      Set I <-- 0, N <-- 0
STEP 2.       Read N
STEP 3.       Repeat for I =0, 1, 2, … N-1
Begin
                                      Print I
End

  

Method 2
STEP 1.      Set I <-- 0, N <-- 0
STEP 2.       Read N
STEP 3.       while (I<=N-1)
                Begin
                                   Print I
                                   I<--I+1
                        End


No comments:

Post a Comment