Monday, 18 February 2019

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 greater than 4 are Goldbach numbers.
Example:
6 = 3 + 3
10 = 3 + 7
10 = 5 + 5
Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3, 7 and 5, 5.
Write a program to accept an even integer ‘N’ where N > 9 and N < 50. Find all the odd prime pairs whose sum is equal to the number ‘N’.
Test your program with the following data and some random data:
Example 1:
INPUT:
N = 14
OUTPUT:
Prime pairs are:
3, 11
7, 7
Example 2:
INPUT:
N = 30
OUTPUT:
Prime numbers are:
7, 23
11, 19
13, 17
Example 3:
INPUT:
N = 17
OUTPUT:
Invalid input. Number is odd.
Example 4:
INPUT:
N = 126
OUTPUT:
Invalid input. Number is out of range.


Friday, 15 February 2019

Quiz ISC17

Question:
The result of a quiz competition is to be prepared as follows:
The quiz has five questions with four multiple choices (A, B, C, D), with each question carrying 1 mark for the correct answer. Design a program to accept the number of participants N such that N must be greater than 3 and less than 11. Create a double dimensional array of size (Nx5) to store the answers of each participant row-wise.
Calculate the marks for each participant by matching the correct answer stored in a single dimensional array of size 5. Display the scores for each participant and also the participant(s) having the highest score.
Example: If the value of N = 4, then the array would be:
Note: Array entries are line fed (i.e. one entry per line)
Test your program with the sample data and some random data:

Example 1
INPUT : N = 5
Participant 1 D A B C C
Participant 2 A A D C B
Participant 3 B A C D B
Participant 4 D A D C B
Participant 5 B C A D D
Key: B C D A A
OUTPUT : Scores :
Participant 1 D A B C C
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2
Highest score: Participant 5
Example 2
INPUT : N = 4
Participant 1 A C C B D
Participant 2 B C A A C
Participant 3 B C B A A
Participant 4 C C D D B
Key: A C D B B
OUTPUT : Scores :
Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3
Highest score:
Participant 1
Participant 4
Example 3
INPUT : N = 12
OUTPUT : INPUT SIZE OUT OF RANGE.

Box Packing ISC17

Question : A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12 boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by the user (maximum up to 1000 boxes) and display the break-up of the cartons used in descending order of capacity (i.e. preference should be given to the highest capacity available, and if boxes left are less than 6, an extra carton of capacity 6 should be used.)
Test your program with the sample data and some random data:
Example 1
INPUT : N = 726
OUTPUT :
48 x 15 = 720
6 x 1 = 6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
Example 2
INPUT : N = 140
OUTPUT :
48 X 2 = 96
24 x 1 = 24
12 x 1 = 12
6 x 1 = 6
Remaining boxes 2 x 1 = 2
Total number of boxes = 140
Total number of cartons = 6
Example 3
INPUT : N = 4296
OUTPUT : INVALID LENGTH

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.

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 ...