Wednesday, 1 February 2017

Sentence Sorting...

Accept a paragraph Of text cons of sentences that are terminated by either ' . ' (fun stop), '!' (exclamation mark) or a '?' (question mark). Assume that there can be maximum 10 sentences in a paragraph. Write a program to arrange the sentences n increasing order of their number of words.
Example : 
INPUT : Please come and attend the party. Hello! How are you? 
OUTPUT : 
Hello = 1 
How are you = 3
Please come and attend the party = 6 

Monday, 30 January 2017

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which all theelements below the diagonal are zero. We consider a Matrix U with ‘i’ rows and ‘j’ columns, thenmathematically we represent the upper triangular matrix as

                                                             upper-triangular-matrix-formula.gif (130×42)
In another word strictly upper triangular matrix is an upper triangular matrix having 0’s along the diagonal as well, i.e., U(ij)=0 for i>=j.
                                                             UpperTriangularMatrix.gif (147×76)

spiral matrix






Outer spiral matrix– arrows are from boundary to core element. Inner Spiral matrix– Arrows are from core elements to boundary elements.

Program for Matrix Multiplication in JAVA...

Matrix Multiplication:– Here is given a Java Program for Matrix Multiplication also call matrix product. In other words, Let the two matrix to be multiplied be A and B. Let A is an n × m order matrix and B is an m × p order matrix, their matrix product A*B is an n × p order matrix, in which the m entries across the rows of A are multiplied with the m entries down the columns of B.

Steps for Matrix Multiplication in Java:

Step 1: Make sure that the the number of columns in the 1st matrix equals the number of rows in the 2nd matrix.
Step 2: Multiply the elements of each row of the first matrix by the elements of each column in the second matrix.
Step 3: Add the products.




Iteration 1
Multiplication of matrix A’s first row with each element of matrix B’s all columns,
1*1+2*5, 1*2+2*6, 1*3+2*7, 1*4+2*8
Iteration 2
Multiplication of matrix A’s second row with each element of matrix B’s all columns,
3*1+4*5, 3*2+4*6, 3*3+4*7, 3*4+4*8
Iteration 3
Multiplication of matrix A’s third row with each element of matrix B’s all columns,
5*1+6*5, 5*2+6*6, 5*3+6*7, 5*4+6*8
Iteration 4
Add all the multiplication and get the matrix with an order 3*4.

Mobius Function of number...

The MOBIUS function µ(n) for a natural number N is defined as follows:
µ(n) = 1 if n is a square free positive integer with an even number of prime factors.
µ(n) = 0 if n has a squared prime factor.
µ(n) = -1 if n is a square free positive integer with an odd number of prime factors.
Example:
µ(26)=1                ( for 26 = 2 * 13     µ(26) = ( -1)^2= 1 )
µ(19)=-1               ( for 19 = 19     µ(19) = ( -1)^1= -1 )
µ(62)=1                ( for 62 = 2 * 31     µ(61) = ( -1)^2= 1 )
µ(28)=0                ( for 28 = 2 * 2 * 7     µ(28) = 0 for 2 appears two times )

Thursday, 19 January 2017

Days Elapsed...

Write a program to input two valid dates, each comprising of day          (2 digits), Month (2 digits) and year (4 digits) and calculate the days elapsed between the two dates. Test your program for the following data values:
i) FIRST DATE :              DAY : 24
                                      MONTH: 09
                                      YEAR: 1960
   SECOND DATE :           DAY : 08
                                      MONTH: 12
                                      YEAR: 1852
       
ii) FIRST DATE :             DAY : 10
                                      MONTH: 01
                                      YEAR: 1852
   SECONDDATE :             DAY : 16
                                       MONTH: 10

                                       YEAR: 1952                

Graph...

A sentence is terminated by either “ . ” , “ ! ” or “ ? ” followed by a space. Input a piece of text consisting of sentences. Assume that there will be a maximum of 10 sentences in a block.
Write a program to:
(i)Obtain the length of the sentence (measured in words) and the frequency of vowels in each sentence.
(ii)Generate the output as shown below using the given data
INPUT                   HELLO! HOW ARE YOU? HOPE EVERYTHING IS FINE. BEST OF LUCK.
OUTPUT      Sentence No. of Vowels No. of words
Sentence                No. of vowels          No. of words
1                           2                           1
2                           5                           3
3                           8                            4
4                           3                            3
Sentence                                   No. of words/vowels
1                                              VVVVVV
1                                              WWW
2                                              VVVVVVVVVVVVVVV
2                                              WWWWWWWWWWWW
3                                              VVVVVVVVVVVVVVVVVVVVVVVV
3                                              WWWWWWWWWWWWWWW
4                                              VVVVVVVVV
4                                              WWWWWWWWWWWW

                   Scale used 1:3

Goldbach Number ISC 2018

Question: A Goldbach number is a positive even integer that can be expressed as the sum of two odd primes. Note: All even integer numbers ...