191,503 views
33 votes
33 votes
Write an algorithm and draw a flowchart to count the digits present in the given integer. ​

User Mubin
by
3.0k points

1 Answer

21 votes
21 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 Piccolo
by
2.4k points