Computer Science 2024 PDF
Computer Science 2024 PDF
PAPER-2
PRACTICAL
(Maximum Marks:30)
Time allowed: Three Hours
(Candidates are allowed additional 15 minutes for only reading the paper)
They must NOT start writing during this time)
The total time to be spent on the Planning Session and the Examination Session is Three hours. After
completing the Planning Session, the candidate may begin with the Examination Session.
A maximum of 90 minutes is permitted for the Planning Session.
However, if candidate finish earlier, they are to be permitted to begin the Examination Session.
This paper consists of three problems from which candidates are required to attempt any one problem.
Candidates are expected to do the following
A. Planning Session:
1. Write an algorithm for the selected problem. [3 marks]
(Algorithm should be expressed clearly using any standard scheme such as pseudo code or in steps
which are simple enough to be obviously complete.)
2. Write a program in JAVA language. The program should follow the [7 marks]
algorithm and should be logically and syntactically correct. Document the program using mnemonic
names/comments, identifying and clearly describing the choice of data types and meaning of variable.
B. Examination Session:
1. Code/Type the program on the computer and get a printout (hard copy). [2 Marks]
Typically, this should be a program that complies and runs correctly.
2. Test run the program on the computer using the given sample data and [3 Marks]
get a printout of the output in the format specified in the problem.
Note: The candidate must not carry any stationery, items such as pen/pencil/ eraser to the Computer
Laboratory for the Examination Session.
Page 1 of 4
Question 1
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 and 7, 5 and 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 PAIRS 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 OUT OF RANGE.
Page 2 of 4
Question 2
Write a program to declare a square matrix M[][] of order ‘N’. Check if the matrix is a Doubly
Markov matrix or not. A matrix which satisfies the following conditions are Doubly Markov matrix
Accept ‘N’ from the user where 3 <= N <= 9. Display an appropriate error message if ‘N’ is not in
the given range or the entered numbers are negative. Allow the user to create a matrix and check
whether the created matrix is a Doubly Markov matrix or not
Test your program for the following data and some random data:
Example 1
INPUT: N=3
Enter elements in the matrix: 0.5, 0.25, 0.25, 0.25, 0.75, 0.0, 0.25, 0.0, 0.75
OUTPUT: FORMED MATRIX
0.5 0.25 0.25
0.25 0.75 0.0
0.25 0.0 0.75
IT IS A DOUBLY MARKOV MATRIX
Example 2
INPUT: N=3
Enter elements in the matrix: 1.5, 3, 0.15, 0.25, 4, 1.0, 0.25, 1.0, 3
OUTPUT: FORMED MATRIX
1.5 3 0.15
0.25 4 1.0
0.25 1.0 3
IT IS NOT A DOUBLY MARKOV MATRIX
Example 3
INPUT: N=2
Enter elements in the matrix: 0.8, -4.0, 0.9, 3.5
OUTPUT: NEGATIVE NUMBERS ENTERED. INVALID ENTRY
Example 4
INPUT: N =12
OUTPUT: SIZE IS OUT OF RANGE. INVALID ENTRY
Page 3 of 4
Question 3
Write a program to accept a sentence which may be terminated by either '.', '?' or '!' only. The words may be
separated by more than one blank space and are in UPPER CASE.
Test your program with the sample data and some random data:
Example 1
INPUT:
ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.
OUTPUT:
NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL = 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL
Example 2
INPUT:
YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY.
OUTPUT:
NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL = 2
A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY
Example 3
INPUT:
LOOK BEFORE YOU LEAP.
OUTPUT:
NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL = 0
LOOK BEFORE YOU LEAP
Example 4
INPUT:
HOW ARE YOU@
OUTPUT:
INVALID INPUT
Page 4 of 4