Page 123 - Computer science 868 Class 12
P. 123

6.  Write an algorithm to find the smallest among three numbers.
                    7.  Write an algorithm to accept any number and print whether it is a positive number, negative number or zero.
                    8.  Write an algorithm to accept three angles of a triangle. Check if the triangle is possible or not and predict whether it is an
                       acute-angled, obtuse-angled or right-angled triangle.
                       The properties of a triangle are given below.
                       a.  The sum of the three angles of a triangle is 180°.
                       b.  In acute-angles triangle, all three angles are less than 90°.
                       c.  In right-angled triangle, one angle is 90°.
                       d.  In obtuse-angled triangle, one angle is greater than 90°.
                    9.  Write an algorithm to accept three sides of a triangle. Check if the triangle is possible or not and predict it is an equilateral,
                       isosceles or scalene triangle. The properties of a triangle are given below.
                       a.  In a triangle, any side is less than the sum of the other two sides.
                       b.  In an equilateral triangle, all sides are equal.
                       c.  In an isosceles triangle, any two sides are equal.
                       d.  In a scalene triangle, all three sides are unequal.
                   10.  Write an algorithm to accept an integer decimal number and perform the following conversion:
                       a.  Convert it to Binary
                       b.  Convert it to Octal
                       c.  Convert it to Hexadecimal
                       For reference, check Chapter 1 Number System of this book.
                   11.  Write an algorithm to enter the number of terms ‘n’ and print the numbers of a Pell Series. Pell Series is a series where each term
                       is the sum of twice the previous number and the number previous to that. The first and the second term of the series are 1 and 2.
                        Mathematically, the next two terms are calculated as follow:
                        rd
                        3  term = 1 + 2*2 = 5
                        4  term = 2 + 5*2 = 12, and so on.
                        th
                       The first 5 terms of a Pell Series are 1, 2, 5, 12, and 29.
                   12.  Write an algorithm to accept any number and print its prime factors. Prime factors of a number are the proper divisors that are
                       prime. Some examples are given below.
                        The prime factors of 24 are 2, 2, 2, 3 as 2 × 2 × 2 × 3 = 24
                        The prime factors of 27 are 3, 3, 3 as 3 × 3 × 3 = 27
                   13.  Write an algorithm to search any number ‘s’ from a single dimensional array ‘a[ ]’ and if found, replace it with another number
                       ‘n’. Use a linear search algorithm to search the number. Assume that the array is already created.
                   14.  Write an algorithm to find the mean and standard deviation of ‘n’ numbers stored in a single-dimensional array. Assume that the
                       array is already created.
                        Hint:  The mean will be = a[0]+a[1]+a[2]+…..a[n-1] / n
                            Standard deviation will be calculated as:
                                                     2
                                                                       2
                            √ ((a[0] - mean)  + (a[1] - mean)  ………  + (a[n-1] - mean) ))/(n-1)
                                        2
                            The mathematical formula is               X   = Average =  S X i
                                                                                   n
                                                                                            a     2
                                                                                               i (
                                                                                            ∑ X X- )
                                                                     σ   = Standard Deviation =   n-1
                                                                                              n-1
                   15.  Assume two arrays are already created. One stores the names of 10 cities and the other stores the corresponding average
                       temperature. Write an algorithm to sort the array in descending order of average temperature using the Bubble Sort technique.
                   16.  Write an algorithm to generate a mirror matrix of a matrix ‘a[][]’ having ‘r’ rows and ‘c’ columns. Assume that the matrix is already
                       created. An example is given for better understanding.










                                                                                                                       121
                                                                            Implementation of Algorithms to Solve Problems  121
   118   119   120   121   122   123   124   125   126   127   128