Computer Science, asked by kesarapuprasad5843, 8 months ago

Following is an algorithm to classify numbers as
"Single Digit", "Double Digit" or "Big".
Classify_Numbers_Algo
INPUT Number
IF Number < 9
"Single Digit"
Else If Number < 99
"Double Digit"
Else "Big"
Verify for (5, 9, 47, 99, 100 200) and correct the algorithm if required

Answers

Answered by BlessyThomas
1

Answer:

If number = 5 then

number<9 # since 5 is smaller than 9 , the first if statement will be true and this statement will execute and print"Single"

If number = 9

If Number<9

"Single digit"

here number should be smaller than 9 then it will execute single digit

it will print double digit

since 9 is also a single digit,this code is not correct.

number = 47

since 47 is greater than 9 but smaller than 99 so,

it will print "double digit" which is correct.

number = 99

Here ,in else if condition statement,number 99 is

here number should be smaller than 99 then it will execute and print "big"

since 99 is also a double digit,this code is not correct.

number = 100

here this number 100 is greater than 99 so else statement will execute which will print "Big".

which is correct.

Number = 200

here this number 200 is greater than 99 so else statement will execute which will print "Big".

which is correct.

By verification, we conclude that this algorithm is not correct since it prints 9 as a double digit and also 99 as a big(three digit) which can be misleading.

Correct Algorithm is :

INPUT Number

IF Number < =9

"Single Digit"

Else If Number < =99

"Double Digit"

Else "Big"

Explanation:

hope it helps

Answered by tkckalai
0

Answer:

Step 1: INPUT Number

Step 2: IF Number <= 9

“Single Digit”

Step 3: Else If Number <= 99

“Double Digit”

Step 4: Else

“Big”

Step 5: End IF

Explanation:

For given data,

5 and 9 are single digit number, so it will print “single digit”

47 and 99 are double digit number, so it will print “double digit”

100 and 200 is a three digit number, so it will print “big

Similar questions