161k views
1 vote
Write an algorithm and draw a flowchart to count the digits present in the given integer. ​

User Salihcenap
by
4.9k points

1 Answer

3 votes

Answer:

The algorithm is as follows:

Input number

count = 0

while(number not equal 0)

number = number / 10

count = count + 1

end

Print count

Step-by-step explanation:

This gets input for the integer number

Input number

This initializes count of digits to 0

count = 0

The following loop is repeated while number is not 0

while(number not equal 0)

This performs integer division of the number by 10; the resulting division is saved in variable number

number = number / 10

The count variable is incremented by 1

count = count + 1

The loop ends here

end

This prints the count of integers

Print count

See attachment for flowchart

Write an algorithm and draw a flowchart to count the digits present in the given integer-example-1
User Rayx
by
4.7k points