This reply is very useful.Thank you and here is my second attempt
Step 1:Initialize the counter to 0 (j=0)
Step 2:counter is equal to j plus 1(j=j+1)
Step 3:print the value of the counter (print j)
Step 4:if counter is greater than 20 (if j>20)
Step 5:stop
Step 6:else if j is less than 20 (j<20)
Step 7:Add 2 to the value of the counter (j=j+2)
Step 8:print j
Step 9:Repeat steps 4 to 9 until...
User Profile
Collapse
-
algorithm
I have an assignment to write an algorithm to print the first 10 odd numbers and this is my attempt
Initialize the first counter to 1 (i=1)
Initialize the second counter to 0 (j=0)
second counter is equal to second counter plus first counter(j=j+i)
print the value of the second counter (print j)
if second counter is greater than 10 (if j>10)
stop
else if j is less than 10 (j<10)
Add 2...
No activity results to display
Show More
Leave a comment: