Page 84 - TechPluse_C6_Flipbook
P. 84

B.    Algorithm to find the smallest in two numbers A and B.
                  Step 1    Start.
                  Step 2    Read two numbers and store them in A and B.

                  Step 3    Compare number A and B. If A is less than B, print "A is smallest" and go to Step 5.
                  Step 4    Compare number A and B. If B is less than A, print "B is smallest" and go to Step 5.

                  Step 5    Stop.

                  C.    Write an algorithm to input your pet's name and display a message.

                  Step 1    Start.
                  Step 2    Ask the user to input their pet's name.
                  Step 3    Store the pet's name in a variable.

                  Step 4    Print "Your pet's name is”, PetName.
                  Step 5    Stop.

                  D.   Write an algorithm to input the lengths of three sides of a triangle, calculate

                        and display the perimeter of Triangle.
                        (Hint: Perimeter= Side1+Side2+Side3)

                  Step 1    Start.
                  Step 2    Input Side1.

                  Step 3    Input Side2.
                  Step 4    Input Side3.

                  Step 5    Calculate Perimeter=Side1+Side2+Side3.
                  Step 6    Print Perimeter.
                  Step 7    Stop.


                  E.      Write an algorithm to input the NAME and AGE from the user and display if
                        they are minor or adult.
                        The desired output will be:

                        If AGE is greater than 18, display Adult

                        If AGE is less than 18, display Minor
                        The algorithm will be:

                  Step 1    Start.

                  Step 2    Input NAME.
                  Step 3    Input AGE.
                  Step 4    IF AGE > 18 THEN

                            Print NAME, “Adult”.




               82       Premium Edition-VI
   79   80   81   82   83   84   85   86   87   88   89