0% found this document useful (0 votes)
104 views4 pages

ISC Computer Science Practical Paper 2 2015

The document describes three programming questions: 1. Write a program to find the smallest integer greater than a given number M that has digit sums equal to a given number N. The program checks for valid inputs and provides examples. 2. Write a program to accept a square matrix size, populate the matrix, display and rotate it 90 degrees clockwise, and find the sum of corner elements. Examples are provided. 3. Write a program to capitalize the first letter of each word in a given sentence, count vowels and consonants in each word, and display the results. The program checks for valid sentence termination. Examples are provided.

Uploaded by

Sayandeep Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views4 pages

ISC Computer Science Practical Paper 2 2015

The document describes three programming questions: 1. Write a program to find the smallest integer greater than a given number M that has digit sums equal to a given number N. The program checks for valid inputs and provides examples. 2. Write a program to accept a square matrix size, populate the matrix, display and rotate it 90 degrees clockwise, and find the sum of corner elements. Examples are provided. 3. Write a program to capitalize the first letter of each word in a given sentence, count vowels and consonants in each word, and display the results. The program checks for valid sentence termination. Examples are provided.

Uploaded by

Sayandeep Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ISC Computer Science Practical

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:

a) Display the original matrix.


b) Rotate the matrix 90º clockwise as shown below:

Original matrix Rotated matrix


123 741
456 852
789 963
c) Find the sum of the elements of the four corners of the matrix. Test your program
for the following data and some random data:

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

MATRIX AFTER ROTATION

1 2 3
6 5 4
7 8 9

Sum of the corner eements= 20

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

MATRIX AFTER ROTATION

3 1 2 1
7 6 5 2
6 7 8 4
5 4 3 9

Sum of the corner eements= 18

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

INPUT : Intelligence plus character is education.

OUTPUT:

Intelligence plus character is education.

Word Vowels Consonants


Intelligence 5 7
Plus 1 3
Character 3 6
Is 1 1
Education 5 4

Example 2

INPUT : God is great.

OUTPUT:

God is great

Word Vowels Consonants


God 1 2
Is 1 1
Great 2 3

You might also like