.Write an algorithm and draw a flowchart to print N odd numbers.
Answers
Answer:
Step 1: Start
Step 2: Declare variable c of integer type
Step 3: Set c=0
Step 4: Repeat step 4.1 to 4.3 while (c<=100)
Step 4.1: if (c%2 != 0)
Step 4.2: then print c
Step 4.3 : c=c+1
Step 5: Stop
Explanation:
Declare x as an integer variable, then Set x=0 and get "n" value then While (x<=n), repeat steps 5–7. if (x%2 != 0) then print x and x=x+1.
Algorithm for print N odd numbers :
⇒ Declare x as an integer variable, then Set x=0 and get "n" value then While (x<=n), repeat steps 5–7. if (x%2 != 0) then print x and x=x+1.
Step 1: Start
Step 2: Declare x as an integer variable.
Step 3: Set x=0
Step 4: Determine the value of n in integers.
Step 5: While (x<=n), repeat steps 5–7.
Step 6: if (x%2 != 0)
Step 7: then print x
Step 8 : x=x+1
Step 9: Stop