ISC Practical Expected Questions

For programs/solutions of question and discussion visit my blog

http://kumardks.blogspot.com/

1.   Binary Conversions     

   The Hamming distance between two bit patterns of same length is the number of bit

   positions at which they (bits) differ. For example, the Hamming distance between

   11101010 and 00011001 is 6, since they differ at 1st , 2nd, 3rd , 4th, 7th, and 8th

    positions.

    Write a program, which inputs 2 non-negative integers, determines their binary

    representation and outputs the Hamming distance between their binary

    representations.

   

2. Mobius function

  The MOBIUS function M( N) for a natural number N is defined as follows:

    M( N) = 1                 if N = 1  

               = 0                 if any prime factor of N is contained in N more than once

               = ( -1)^ P     if N is a product of p distinct prime factors

Example :

M( 78) = -1                ( for 78 = 2 * 3 * 13     M( 78) = ( -1)^ 3 = -1 )

M( 34) = 1                 ( for 34 = 2 * 17           M( 34) = ( -1) ^2 = 1 )

M( 12) = 0                 ( for 12 = 2 * 2 * 3       M( 12) = 0 for 2 appears two times)

M( 17) = -1                ( for 17 = 17                M( 17) = ( -1)^ 1 = -1 )

Write a program to input natural number N and output M( N).

4.   Sorting Rows/ Columns of 2D Array

Write a program to create a matrix A[ ][ ] of size m x n.

Input values of m and n.

Input integers into this matrix from the user.

Sort the elements of each COLUMN of the array in descending order using any standard sorting technique. Output the original and sorted matrix:

Example

        m  =  3             n = 3

        9        4       6

        10      7       8

        6        3       5

Sorted array

       6       3       5

       9       4       6

       10     7       8

OR

Write a program to create a matrix A[ ][ ] of size m x n.

Input values of m and n.

Input integers into this matrix from the user.

Sort the elements of each ROW of the array in descending order using any standard sorting technique. Output the original and sorted matrix:

Example

        m  =  3            n = 3

        9       4      6

        10    7       8

        6      3       5

Sorted array

       4       6       9

       7       8      10

       3       5       6

5.   Finding maximum and minimum value of a 2D Array

Given a square matrix list[ ][ ] of order ‘n’. The maximum value possible for ‘n’ is 20. Input the value for ‘n’ and the positive integers in the matrix and perform the following tasks:

(a)          Display the original matrix

(b)         Print the row and column position of the largest element of the matrix

(c)          Print the row the column  position of the smallest element of the matrix

            INPUT:          N=3

            List [ ][ ]          5          1          3

                                    7          4          6

                                    9          8          2

            OUTPUT

                                    5          1          3

                                    7          4          6

                                    9          8          2

            The largest element 9 is in row 3 and column 1

            The smallest element 1 is in row 1 and column 2

6.   Reversing words of a sentence

7.   Finding common words from two sentences

8.   Sorting of words of a sentence