Practical Complete Papers
Practical Complete Papers
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.
Planning session: 90 minutes
Examination session: 90 minutes
Note: Candidates are to be permitted to proceed to the Examination Session only after 90 minutes of
the Planning session are over.
This paper consists of three problems from which candidates are required to attempt any one problem.
Candidates are expected to do the following:
In addition to the above, the practical file of the candidate containing the practical work related to
programming assignments done during the year is to be evaluated as follows:
* Programming assignments done throughout the year (by the teacher) [5]
* Programming assignments done throughout the year (by the Visiting Examiner) [5]
Question 2
Write a program to declare a single dimensional array a[] and a square matrix b[][] of Size N, where N>2
and N<10. Allow the user to input positive integers into the single dimensional array. Perform the following
tasks on the matrix:
Sort the elements of the single dimensional array in ascending order using any standard sorting technique
and display the sorted elements.
Fill the square matrix b[][] in the following format.
If the array a[ ]= { 5, 2, 8,1 } then, after sorting a={1,2,5,8}
Then, the matrix b[][] would fill as below:
1 2 5 8
1 2 5 1
1 2 1 2
1 1 2 5
Display the filled matrix in the above format
Test your program for the following data and some random data:
Example 1
INPUT: N =3
ENTER ELEMENTS OF SINGLE DIMENSIONAL ARRAY: 3 1 7
OUTPUT:
SORTED ARRAY: 1 3 7
FILLED MATRIX
137
131
113
Example 2
INPUT: N=13
OUTPUT:
MATRIX SIZE OUT OF RANGE
EXAMPLE 3
ENTER ELEMENTS OF SINGLE DIMENSTIONAL ARRAY: 10 2 5 23 6
OUTPUT SORTED ARRAY: 2 3 6 10 23
FILLED MATRIX
2 5 6 10 23
2 5 6 10 2
2 5 6 2 5
2 5 2 5 6
2 2 5 6 10
Question 3
Write a program to accept a sentence which may be terminated by either ’.’,’?' or ’!' only. The word are to
be separated by a single blank space and are in UPPERCASE.
Perform the following tasks:
(a) Check for the validity of the accepted sentence.
(b) Convert the non-palindrome words of the sentence into palindrome words by concatenating the word by
its reverse (excluding the last character.)
For example: The reverse of the word HELP would be LEH (omitting the last alphabet and by concatenating
both, the new palindrome word is HELPLEH. Thus, the word HELP becomes HELPLEH.
Note: The words which end with repeated alphabets, for example ABB would become ABBA and not
ABBBA and XAZZZ becomes XAZZZAX.
(Palindrome word: Spells same from either side. Example: DAD. MADAM etc.]
(c) Display the original sentence along with the converted sentence.
Test your program for the following data and some random data:
Example 1
INPUT: THE BIRD IS FLYING.
OUTPUT: THE BIRD IS FLYING.
THEHT BIRDRIB ISI FLYINGNIYLF
Example 2
INPUT: IS THE WATER LEVEL RISING.
OUTPUT: IS THE WATER LEVEL RISING.
ISI THEHT WATERETAW LEVEL RISINGNISIR
Example 3
INPUT: THE MOBILE APP LOOKS FINE.
OUTPUT: THE MOBILE APP LOOKS FINE.
THISIHT MOBILELIBOM APPA LOOKSKOOL FINENIF
Example 4
INPUT: YOU MUST BE CRAZY#
OUTPUT: INVALID INPUT
ISC 2018
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.
Question 2
Write a program to declare a matrix A[ ] [ ] of order (MxN) where ‘M’ is the number of rows and N’ is the
number of columns such that the values of both ‘M’ and ‘N’ must be greater than 2 and less than 10. Allow
the user to input integers into this matrix. Perform the following tasks on the matrix:
(a) Display the original matrix.
(b) Sort each row of the matrix in ascending order using any standard sorting technique.
(c) Display the changed matrix after sorting each row.
Test your program for the following data and some random data:
Example 1:
INPUT: M=4
N=3
ENTER ELEMENTS OF MATRIX
11 -2 3
5 16 7
9 0 4
3 1 8
OUTPUT:
ORIGINAL MATRIX
11 -2 3
5 16 7
9 0 4
3 1 8
OUTPUT:
ORIGINAL MATRIX
22 5 19
7 36 12
9 13 6
MATRIX AFTER SORTING ROWS
5 19 22
7 12 36
6 9 13
Example 3:
INPUT: M =11
N=5
OUTPUT:
MATRIX SIZE OUT OF RANGE
Question 3
The names of the teams participating in a competition should be displayed on a banner vertically, to
accommodate as many teams as possible in a single banner. Design a program to accept the names of N
teams, where 2 < N < 9 and display them in vertical order, side by side with a horizontal tab (i.e. eight
spaces).
Test your program for the following data and some random data:
Example 1:
INPUT: N=3
Team 1: Emus
Team 2: Road Rols
Team 3: Coyote
E R C
m o o
u a y
s d o
t
R e
o
1
s
Example 2:
INPUT: N=4
Team 1: Royal
Team 2: Mars
Team 3: De Rose
Team 4: Kings
OUTPUT:
R M D K
o a e i
y r n
a s R g
1 o s
s
e
Example 3
INPUT: N = 10
OUTPUT: INVALID INPUT
ISC 2017
Question 1
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 following data and some random data:
Example 1
INPUT: N = 726
OUTPUT: 48 x 15 = 720
6 x1 =6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
Example 2
INPUT: N = 140
48 x 2 = 96
24 x 1 = 24
12 x 1 = 12
6 x1 =6
Remaining boxes 2 x 1 = 2
Total number of boxes = 140
Total number of cartons = 6
Example 3
INPUT: N = 4296
OUTPUT: INVALID INPUT
Question 2
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 1I mark for
the correct answer. Design a program to accept the number of participant’s N such that N must be greater
than 3 and less than 11. Create a double dimensional array of size (N><5) 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:
Q.l Q.2 Q.3 Q.4 Q.5
Participant 1 A B B C A
Participant 2 D A D C B
Participant 3 A A B A C
Participant 4 D C C A B
Note: Array entries are linefed (i.e. one entry per line)
Test your program for the following data and some random data:
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 C
Key: B C D A A
Scores:
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2
Highest score: Participant 5
N=4
Participant 1 ACCBD
Participant 2 BCAAC
Participant 3 BCBAA
Participant 4 CCDDB
Key: ACDBB
Scores:
Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3
Highest score: Participant 1
Participant 4
N = 12
INPUT SIZE OUT OF RANGE
Question 3
Caesar Cipher is an encryption technique which is implemented as ROT13 (‘rotate by 13 places’). It is a
simple letter substitution cipher that replaces a letter with the letter 13 places after it in the alphabets, with
the other characters remaining unchanged.
ROT13
A/a B/b C/c D/d E/e F/f G/g H/h I/i J/j K/k L/l M/m
N/n O/o P/p Q/q R/r S/s T/t U/u V/v W/w X/x Y/y Z/z
Write a program to accept a plain text of length L, where L must be greater than 3 and less than 100.
Encrypt the text if valid as per the Caesar Cipher.
Test your program with the sample data and some random data:
Example 1
INPUT: Hello! How are you?
OUTPUT: The cipher text is:
Uryyb? Ubj ner lbh?
Question 2
Write a program to declare a square matrix A[ ] [ ] of order (MxM) where ‘M’ must be greater than 3 and
less than 10. Allow the user to input positive integers into this matrix. Perform the following tasks on the
matrix:
Sort the non-boundary elements in ascending order using any standard sorting technique and rearrange them
in the matrix.
Calculate the sum of both the diagonals.
Display the original matrix, rearranged matrix and only the diagonal elements of the rearranged matrix with
their sum.
Test your program for the following data and some random data:
Example 1
INPUT: M = 4
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
OUTPUT:
ORIGINAL MATRIX
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
REARRANGED MATRIX
9 2 1 5
8 3 6 4
15 8 13 11
7 12 23 8
DIAGONAL ELEMENTS
9 5
3 6
8 13
7 8
Example 2
INPUT: M=5
7 4 1 9 5
8 2 6 10 19
13 1 3 5 1
10 0 5 12 16
1 8 17 6 8
OUTPUT:
ORIGINAL MATRIX
7 4 1 9 5
8 2 6 10 19
13 1 3 5 1
10 0 5 12 16
1 8 17 6 8
REARRANGED MATRIX
7 4 1 9 5
8 0 1 2 19
13 3 5 5 1
10 6 10 12 16
1 8 17 6 8
DIAGONAL ELEMENTS
7 5
0 2
5
6 12
1 8
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.
Perform the following tasks:
Find the number of words beginning and ending with a vowel. Place the words which begin and end with a
vowel at the beginning, followed by the remaining words as they occur in the sentence.
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
ISC 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 the sample data and some random data:
Example 1
INPUT: M = 100
N = 11
OUTPUT: The required number = 119
Total number of digits = 3
Example 2
INPUT: M = 1500
N = 25
OUTPUT: The required number = 1699
Total number of digits = 4
Example 3
INPUT: M = 99
N = 11
OUTPUT: INVALID INPUT
Example 4
INPUT: M = 112
N = 130
OUTPUT: INVALID INPUT
Question 2
Write a program to declare a square matrix A[ ][ ] of order MxM where 'M' is the number of rows and the
number of columns, such that M must be greater than 2 and less than I 0. Accept the value of M as user
input. Display an appropriate message for an invalid input. Allow the user to input integers into this matrix.
Perform the following tasks:
Display the original matrix.
Rotate the matrix 90° clockwise.
Find and display the sum of corner elements.
Test your program with the sample 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 elements = 20
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 12 1
7 6 5 2
6 7 8 4
5 4 3 9
Sum of the corner elements = 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:
Convert the first letter of each word to uppercase.
Find the number of vowels and consonants in each word and display them with proper headings along with
the words.
Test your program with the following inputs.
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
Example 3
INPUT: All the best!
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 this matrix.
Perform the following tasks:
(a) Display the original matrix.
(b) Check if the given matrix is Symmetric or not.
A square matrix is said to be Symmetric, if the element of the ith row and jth column is equal to the element
of the jth row and ith column.
(c) Find the sum of the elements of left diagonal and the sum of the elements of right diagonal of the matrix
and display them.
Test your program with the sample data and some random data:
Example 1
INPUT : M= 3
1 2 3
2 4 5
3 5 6
OUTPUT :
ORIGINAL MATRIX
1 2 3
2 4 5
3 5 6
Example 2
INPUT : M=4
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
OUTPUT :
ORIGINAL MATRIX
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
THE GIVEN MATRIX IS NOT SYMMETRIC
The sum of the left diagonal = 17 The sum of the right diagonal = 20
Example 3
INPUT : M = 22
OUTPUT : THE MATRIX SIZE IS OUT OF RANGE
Question 3
Write a program to accept a sentence which may be terminated by either ‘.’ ‘?’ or ‘!’ only. Any other
character may be ignored. The words may be separated by more than one blank space and are in UPPER
CASE.
Perform the following tasks:
(a) Accept the sentence and reduce all the extra blank space between two words to a single blank space.
(b) Accept a word from the user which is part of the sentence along with its position number and delete the
word and display the sentence.
Test your program with the sample data and some random data:
Example 1
INPUT: A MORNING WALK IS A IS BLESSING FOR THE WHOLE DAY.
WORD TO BE DELETED: IS
WORD POSITION IN THE SENTENCE: 6
OUTPUT: A MORNING WALK IS A BLESSING FOR THE WHOLE DAY.
Example 2
INPUT: AS YOU SOW, SO SO YOU REAP.
WORD TO BE DELETED: SO WORD POSITION IN THE SENTENCE: 4
OUTPUT: AS YOU SOW, SO YOU REAP.
Example 3
INPUT: STUDY WELL ##.
OUTPUT: INVALID INPUT.
ISC 2013
Question 1
An ISBN (International Standard Book Number) is a ten digit code which uniquely identifies a book.
The first nine digits represent the Group, Publisher and Title of the book and the last digit is used to check
whether ISBN is correct or not.
Each of the first nine digits of the code can take a value between 0 and 9. Sometimes it is necessary to make
the last digit equal to ten; this is done by writing the last digit of the code as X.
To verify an ISBN, calculate 10 times the first digit, plus 9 times the second digit, plus 8 times the third and
so on until we add 1 time the last digit. If the final number leaves no remainder when divided by 11, the
code is a valid ISBN.
For Example:
0201103311 = 10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55 Since 55 leaves no
remainder when divided by 11, hence it is a valid ISBN.
007462542X = 10*0 + 9*0 + 8*7 + 7*4 + 6*6 + 5*2 + 4*5 + 3*4 + 2*2 + 1*10 = 176 Since 176 leaves no
remainder when divided by 11, hence it is a valid ISBN.
0112112425 = 10*0 + 9*1 + 8*1 + 7*2 + 6*1 + 5*1 + 4*1 + 3*4 + 2*2 + 1*5 = 71
Since 71 leaves no remainder when divided by 11, hence it is not a valid ISBN.
Design a program to accept a ten digit code from the user. For an invalid input, display an appropriate
message. Verify the code for its validity in the format specified below:
Test your program with the sample data and some random data:
Example 1
INPUT CODE 0201530821
OUTPUT SUM = 99
LEAVES NO REMAINDER - VALID ISBN CODE
Example 2
INPUT CODE 035680324
OUTPUT INVALID INPUT
Example 2
INPUT CODE 0231428031
OUTPUT SUM = 122
LEAVES REMAINDER - INVALID ISBN CODE
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 20. Allow the user to input integers
into this matrix. Display appropriate error message for an invalid input. Perform the following tasks:
Display the input matrix.
Create a mirror image matrix.
Display the mirror image matrix.
Test your program with the sample data and some random data:
Example 1
INPUT : M =3
4 16 12
8 2 14
4 1 3
OUTPUT :
ORIGINAL MATRIX
4 16 12
8 2 14
4 1 3
MIRROR IMAGE MATRIX
12 16 4
14 2 8
3 1 6
Example 2
INPUT : M = 22
OUTPUT : SIZE OUT OF RANGE
Question 3
A Palindrome is a word that may be read the same way in either direction. Accept a sentence in UPPER
CASE which is terminated by either ” .”, ?,” or ” ! “ Each word of the sentence is separated by a single blank
space. Perform the following tasks:
Display the count of palindromic words in the sentence.
Display the palindromic words in the sentence.
Example of palindromic words:
MADAM, ARORA, NOON
Test your program with the sample data and some random data:
Example 1
INPUT : MOM AND DAD ARE COMING AT NOON.
OUTPUT : MOM DAD NOON
NUMBER OF PALINDROMIC WORDS :3
Example 2
INPUT : NITIN ARORA USES LIRIL SOAP.
OUTPUT : NITIN ARORA LIRIL
NUMBER OF PALINDROMIC WORDS: 3
Example 3
INPUT : HOW ARE YOU?
OUTPUT : NO PALINDROMIC WORDS
ISC 2012
Question 1
A prime palindrome integer is a positive integer (without leading zeros) which is prime as well as a
palindrome. Given two positive integers m and n, where m < n, write a program to determine how many
prime-palindrome integers are there in the range between m and n (both inclusive) and output them.
The input contains two positive integers m and n where m < 3000 and n < 3000. Display the number of
prime-palindrome integers in the specified range along with their values in the format specified below:
Test your program with the sample data and some random data:
Example 1
INPUT: m = 100
n = 1000
OUTPUT: THE PRIME PALINDROME INTEGERS ARE:
101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, and 929 FREQUENCY OF PRIME
PALINDROME INTEGERS: 15
Example 2
INPUT: m = 100
n = 5000
OUTPUT: OUT OF RANGE
Question 2
Write a program to accept a sentence as input. The words in the string are to be separated by a blank. Each
word must be in upper case. The sentence is terminated by either “.”,”!” or “?”. Perform the following tasks:
Obtain the length of the sentence (measured in words).
Arrange the sentence in alphabetical order of the words.
Test your program with the sample data and some random data:
Example 1
INPUT:
NECESSITY IS THE MOTHER OF INVENTION.
OUTPUT:
LENGTH: 6
REARRANGED SENTENCE
INVENTION IS MOTHER NECESSITY OF THE
Example 2
INPUT:
BE GOOD TO OTHERS.
OUTPUT:
LENGTH: 4
REARRANGED SENTENCE
BE GOOD OTHERS TO
Question 3
Write a program to declare a matrix A [ ] [ ] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the
number of columns such that both M and N must be greater than 2 and less than 20. Allow the user to input
integers into this matrix. Perform the following tasks on the matrix:
Display the input matrix
Find the maximum and minimum value in the matrix and display them along with their position.
Sort the elements of the matrix in ascending order using any standard sorting technique and rearrange them
in the matrix.
Output the rearranged matrix.
Test your program with the sample data and some random data:
Example 1
INPUT : M=3
N=4
8 7 9 3
-2 0 4 5
1 3 6 -4
OUTPUT :
ORIGINAL MATRIX
8 7 9 3
-2 0 4 5
1 3 6 -4
REARRANGED MATRIX
-4 -2 0 1
3 3 4 5
6 7 8 9
Example 2
INPUT : M=3
N = 22
OUTPUT : SIZE OUT OF RANGE
ISC 2011
Question 1
Write a program to input a natural number less than 1000 and display it in words. Test your program for the
given sample data and some random data.
INPUT: 29
OUTPUT: TWENTY NINE
INPUT: 17001
OUTPUT: OUT OF RANGE
INPUT: 119
OUTPUT: ONE HUNDRED AND NINETEEN
INPUT: 500
OUTPUT: FIVE HUNDRED
Question 2
Encryption is a technique of coding messages to maintain their secrecy, A String array of size ‘n’ where ‘n’
is greater than 1 and less than 10, stores single sentences (each sentence ends with a full stop) in each row of
the array,
Write a program to accept the size of the array, Display an appropriate message if the size is not satisfying
the given condition, Define a string array of the inputted size and fill it with sentences row-wise, Change the
sentence of the odd rows with an encryption of two characters ahead of the original character, Also change
the sentence of the even rows by storing the sentence in reverse order, Display the encrypted sentences as
per the sample data given below:
Example 1
INPUT:
n=4
IT IS CLOUDY,
IT MAY RAIN,
THE WEATHER IS FINE,
IT IS COOL.
OUTPUT:
KV KU ENQWFA,
RAIN MAY IT,
VJG YGCVJGT KU HKPG.
COOL IS IT,
Example 2
INPUT:
n = 13
OUTPUT:
INVALID ENTRY
Test your program on the sample data and some random data,
Design a program which accepts your date of birth in dd mm yyyy format. Check whether the date entered is
valid or not. If it is valid, display “VALID DATE”, also compute and display the day number of the year for
the date of birth. If it is invalid, display “INVALID DATE” and then terminate the program.
Test your program for the given sample data and some random data.
Example 1 :
INPUT: Enter your date of birth in dd mm yyyy format
05
01
2010
OUTPUT: VALID DATE 5
Example 2 :
INPUT: Enter your date of birth in dd mm yyyy format
03
04
2010
OUTPUT: VALID DATE 93
ISC 2010
Question1: A bank intends to design a program to display the denomination of an input amount, up to 5
digits. The available denomination with the bank are of rupees 1000, 500. 100, 50. 20, 10, 5, 2, 1. Design a
program to accept the amount from the user and display the break-up in descending order of denomination,
(i.e. preference should be given to highest denomination available) along with the total number of notes.
[Note : Only the denomination used should be displayed]. Also print the amount in words according to the
digits.
Example 1.
INPUT : 14856
OUTPUT : ONE FOUR EIGHT FIVE SIX
DENOMINATION
1000 X 14 = 14000
500 X 1 = 500
100 X 3 = 300
50 X 1 = 50
5 X 1 = 5
1 X 1 = 1
TOTAL = 14856
TOTAL NUMBER OF NOTES = 21
Question2: A positive whole number ‘n’ that has ‘d’ number of digits is squared and split into two pieces, a
right-hand piece that has ‘cf digits and a left-hand piece that has remaining ‘d’ or ‘d-1’ digits. I f the sum of
the two pieces is equal to the number, then ‘n‘ is a Kaprekar number. The first few Kaprekar numbers are:
9.,45,297
For example 297 is a Kaprekar number because:
2972 = 88209. right-hand piece of 88209 =209 and left-hand piece of 88209 = 88 Sum=209 + 88 = 297, i.e.
equal to the number.
Given the two positive integers p and q. where p<q, write a program to determine how many Kaprekar
numbers are there in the range between p and q( both inclusive) and output them.
The input contains two positive integers p and q. Assume p <5000 and q <5000. You are to output the
number of Kaprekar numbers in the specified range along with their values in the format specified below:
SAMPLE DATA:
INPUT :
P=1
Q=1000
OUTPUT :
THE KAPREKAR NUMBERS ARE :- 1, 9.45. 55. 9, 297, 703. 999
FREQUENCY OF KAPREKAR NUMBERS IS : 8
Question3: Input a paragraph containing ‘n‘ number of sentences where (1=<n<4). The words are to be
separated with a single blank space and are in upper-case. A sentence may be terminated either with a full
stop 7 or a question mark’?’ only. Any other character may be ignored. Perform the following operations:
Accept the number of sentences. If the number of sentences exceeds the limit an appropriate error message
must be displayed.
Find the number of words in the whole paragraph.
Display the words in ascending order of their frequency. Words with same frequency may appear in any
order.
Example 1.
INPUT :
Enter number of sentences : 1
Enter sentences : TO BE OR NOT TO BE.
OUTPUT
Total number of words : 6
WORD FREQUENCY
OR 1
NOT 1
TO 2
BE 2
ISC 2009
Question 1
Design a program to accept a day number (between 1 and 366), year (in 4 digits) from the user to generate
and display the corresponding date. Also accept N (1<=N<=100) from the user to compute and display the
future date corresponding to N days after the generated date. Display an error message if the value of the day
number, year and N are not within the limit or not according to the condition specified.
Test your program for the following data and some random data.
1.Example :
DAY NUMBER : 233
YEAR : 2008
DATE AFTER(N) : 17
OUTPUT
20th AUGUST 2008
DATE AFTER 17 DAYS: 6th SEPTEMBER 2008
2. Example :
DAY NUMBER : 360
YEAR : 2008
DATE AFTER(N) : 45
OUTPUT
20th AUGUST 2008
DATE AFTER 17 DAYS : 8TH FEBRUARY 2009
Question2
Write a program to declare a matrix A[ ][ ] of order (mxn) where m is the number of rows and n is the
number of columns such that both m and n must be greater than 2 and less than 20. Allow the user to input
positive integers into this matrix. Perform the following tasks on the matrix :
a) Sort the elements of the outer row and column elements in ascending order using any standard
sorting technique and arrange them in an array.
b) Calculate the sum of the outer row and column elements.
c) Output the original matrix, rearranged matrix and only the boundary elements of the rearranged array
with their sum.
Test your program for the following data and some random data:
Example: OUTPUT
INPUT: m=3, n=3 ORIGINAL MATRIX
1 7 4
1 7 4 8 2 5 BOUNDARY ELEMENTS
8 2 5 6 3 9 1 3 4
6 3 9 9 5
REARRANGED MATRIX 8 7 6
1 3 4
9 2 5
8 7 6
Question 3:
Read a single sentence which terminates with a full stop(.). The words are to be separated with a single
blank space and are in lower case. Arrange the words contained in the sentence according to the length of
the words in ascending order. If two words are of the same length then the word occurring first in the input
sentence should come first. For both, input and output the sentence must begin in upper-case.
Test your program for the following data and some random data.
INPUT : The lines are printed in reverse order.
OUTPUT : In the are lines order printed reverse.
INPUT : Print the sentence in ascending order.
OUTPUT : In the print order sentence ascending.
INPUT : 1 love my country.
OUTPUT : 1 my love country.
ISC 2008
Q1. A smith number is a composite number, the sum of whose digits is the sum of the digits of its prime
factors obtained as a result of prime factorization (excluding 1). The first few such numbers are 4, 22, 27,
58, 85, 94, 121.
Example;
1. 666
Prime factors are 2, 3, 3 and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+(3+7) = 18
2. 4937775
Prime factors are 3, 5, 5, 65837
Sum of the digits are (4+9+3+7+7+7+5) = 42
Sum of the digits of the factors (3+5+5+(6+5+8+3+7) = 42
Write a program to input a number and display whether the number is a Smith number or not.
Sample data:
Input 94 Output SMITH Number
Input 102 Output NOT SMITH Number
Input 666 Output SMITH Number
Input 999 Output NOT SMITH Number
1 VVVVVV
WWW
2 VVVVVVVVVVVVVVV
WWWWWWWWW
3 VVVVVVVVVVVVVVVVVVVVVVVV
WWWWWWWWWWWW
Scale used 1:3
Q3. Given a square matrix list [ ] [ ] of order ‘ n ’. The maximum value possible for ‘ n ’ is 20. Input the
value for ‘ n ’ and the positive integers in the matrix and perform the following task:
1. Display the original matrix
2. Print the row and column position of the largest element of the matrix.
3. Print the row and column position of the second largest element of the matrix.
4. Sort the elements of the rows in the ascending order and display the new matrix.
Sample data:
INPUT
N = 3 List [] [ ]
5 1 3
7 4 6
9 8 2
OUTPUT
5 1 3
7 4 6
9 8 28
Q2. The input in this problem will consists of a number of lines of English text consisting of the letters of
the English alphabet, the punctuation marks (‘) apostrophe, (.) full stop, (,) comma, (;)semicolon, (:) colon
and white space characters (blank, newline). Your task is to print the word of the text in reverse order
without a punctuation marks other than blanks.
For example consider the following input text:
This is a sample piece of text to illustrate this problem. If you are smart you will solve this right.
The corresponding output would read as:
right this solve will you smart are you If problem this illustrate to text of piece sample a is This.
i.e , the lines are printed in reverse order.
Note: Individual words are not reversed.
Input format
The first line of input contains a single integer N ( < = 20), indicating the number of lines in the input. This
is followed by N lines of input text. Each line should accept a maximum of 80 characters.
Output format
Output the text containing the input lines in reversed order without punctuation except blanks illustrated
above.
Test your program for the following data and some random data.
SAMPLE DATA
INPUT:
2
Emotions, controlled and directed to work, is character.
By Swami Vivekananda.
OUTPUT:
Vivekananda Swami by character is work to directed and controlled Emotions.
INPUT:
1
Do not judge a book by its cover.
OUTPUT
cover its by book a judge not Do.
Q3. A unique-digit integer is a positive integer (without leading zeros) with no duplicates digits. For
example 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not. Given two positive integers
m and n, where m < n, write a program to determine how many unique-digit integers are there in the range
between m and n (both inclusive) and output them.
The input contains two positive integers m and n. Assume m < 30000 and n < 30000. You are to output the
number of unique-digit integers in the specified range along with their values in the format specified below:
SAMPLE DATA:
INPUT:
m = 100 n = 120
OUTPUT:
THE UNIQUE-DIGIT INTEGERS ARE:
102, 103, 104, 105, 106, 107, 108, 109, 120.
FREQUENCY OF UNIQUE-DIGIT INTEGERS IS : 9
INPUT:
m = 2500 n = 2550
OUTPUT:
THE UNIQUE-DIGIT INTEGERS ARE:
2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2517, 2530, 2519, 2530,
2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549.
FREQUENCY OF UNIQUE-DIGIT INTEGERS IS: 28.