2.WRITE AN ALGORITHM TO CALCULATE AND DISPLAY OF THE FOLLOWING SERIES : 1-2+3-4+5.... UPTO N
START
STEP 1: Declare the variable n ,c and i as integer.
STEP 2: Initialize n=c=0 and i=1
STEP 3: Input the value of n
STEP 4: If i<=n then Goto Step 5 else Goto Step 7
STEP 5: If i %2 =0 then c=c-i ,Goto Step 6 else c=c+i , Goto Step 6
STEP 6 : Increment the value of i by 1 and Goto Step 4
STEP 7 : Display the value of c
END
No comments:
Post a Comment