At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.

Using a while loop, create an algorithm extractDigits that prints the individual digits of a positive integer.

Sagot :

Answer:

The algorithm is as follows

1. Start

2. Declare Integer N

3. Input N

4. While N > 0:

4.1    Print(N%10)

4.2   N = N/10

5. Stop

Explanation:

This line starts the algorithm

1. Start

This declares an integer variable

2. Declare Integer N

Here, the program gets user input N

3. Input N

The while iteration begins here and it is repeated as long as N is greater than 0

4. While N > 0:

This calculates and prints N modulus 10; Modulus of 10 gets the individual digit of the input number

4.1    Print(N%10)

This remove the printed digit

4.2   N = N/10

The algorithm ends here

5. Stop

Bonus:

The algorithm in Python is as follows:

n = 102

while n>0:

    print(int(n%10))

    n= int(n/10)

   

Thank you for trusting us with your questions. We're here to help you find accurate answers quickly and efficiently. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.