Page 119 - Computer Science V2.0 Class 11
P. 119

Pseudocode:
                           input num1, num2, and num3

                           if num1 >= num2 and num1 >= num3 then
                               print num1
                           if num2 >= num1 and num2 >= num3 then
                              print num2
                           If num3 >= num2 and num3 >= num1 then
                              print num3
                      Flowchart:

                                    Start



                              input num1, num2,
                                   num3





                                   num1 >         True           num1 >        True     print num1 is greatest
                                   num2                           num3


                                       False                         False



                                   num2 >        False     print num3 is greatest
                                   num3

                                       True

                                print num2 is greatest                                         Stop


                    5.  Write a pseudocode to display the reverse of a number.
                  Ans.  Input: number-num
                        Process: Begin with zero as the reversed number. Extract the last digit of num, append it to reversed, and then remove
                      the last digit from num.
                      Output: the number comprising digits of num in the reversed order
                      input num
                      reverse = 0
                      while num>0 do
                          remainder = num % 10
                          reverse = reverse * 10 + remainder
                          num = num // 10

                      end-while
                      print reverse








                                                                                                     Problem Solving  105
   114   115   116   117   118   119   120   121   122   123   124