Algorithm for printing perfect cubes that are less than the

Algorithm for printing perfect cubes that are less than the input n.

eg. if n=30

1

8

27

Solution

1) start. input n
2) initialize a loop control variable i to 1 (i =1)
3) initialize a variable current_cube to 0
4)start a for or while loop with condition say (current_cube<n)
5) increment i for each iteration
6) calculate cube of i for every iteration,print it and store it in \"current_cube \" variable and the same is used to check the condition of loop until the \"current cube\" value is less than n
Exit the loop when condition fails.
7)stop

Algorithm for printing perfect cubes that are less than the input n. eg. if n=30 1 8 27Solution1) start. input n 2) initialize a loop control variable i to 1 (i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site