ISC Computer Science Practical Paper 2 2015
ISC Computer Science Practical Paper 2 2015
Paper 2
2015
Question 1.
Given two positive numbers M and N, such that M is between 100 and 10000 and N is
less than 100. Find the smallest integer that is greater than M and whose digits add up to
N. For example, if M=100 and N=11, then the smallest integer greater than 100 whose
digits add up to 11 is 119.
Write a program to accept the numbers M and N from the user and print the smallest
required number whose sum of all its digits is equal to N. Also, print the total number of
digits present in the required number. The program should check for the validity of the
inputs and display an appropriate message for an invalid input.
Test your program with some sample data and some random data:
Example 1:
INPUT : M= 100
N=11
OUTPUT:
The required number is= 119
Total number of digits=3
Example 2
INPUT: M= 1500
N=25
OUTPUT:
The required number is =1699
Total number of digits=4
Example 3
INPUT: M= 99
N=11
OUTPUT:
INVALID INPUT
Example 4
INPUT: M= 112
1
N=130
OUTPUT:
INVALID INPUT
Question 2.
Write a program to declare a square matrix A[][] of order M x M where ‘M’ is the
number of rows and the number of columns, such that M must be greater than 2 and less
than 10. Accept the value of M as user input. Display an appropriate message for an
invalid input. Allow the user to input integers into the matrix. Perform the following
tasks:
Example 1:
INPUT : M=3
3 4 9
2 5 8
1 6 7
OUTPUT:
ORIGINAL MATRIX
3 4 9
2 5 8
1 6 7
1 2 3
6 5 4
7 8 9
2
Example 2:
INPUT : M=4
1 2 4 9
2 5 8 3
1 6 7 4
3 7 6 5
OUTPUT:
ORIGINAL MATRIX
1 2 4 9
2 5 8 3
1 6 7 4
3 7 6 5
3 1 2 1
7 6 5 2
6 7 8 4
5 4 3 9
EXAMPLE 3.
INPUT : M = 14
OUTPUT:
SIZE OUT OF RANGE
Question 3.
Write a program to accept a sentence which may be terminated by either ‘.’ Or ‘?’ only.
The words are to be separated by a single blank space. Print an error message if the input
does not terminate with ‘.’ Or ‘?’. You can assume that no word in the sentence exceeds
15 characters, so that you get a proper formatted output. Perform the following tasks:
i) Convert the first letter of each word to uppercase.
ii) Find the number of vowels and consonants in each word and display them
with proper heading along with the words.
Test your program with the following inputs:
3
Example 1
OUTPUT:
Example 2
OUTPUT:
God is great