Common Practical Paper Questions For Computer Isc
Common Practical Paper Questions For Computer Isc
Common Practical Paper Questions For Computer Isc
1|Page
COMPUTER PROJECT
2|Page
COMPUTER PROJECT
3|Page
COMPUTER PROJECT
4|Page
COMPUTER PROJECT
2. Write a program in java to accept date and weekdays name of the 1 st day of that month. Display
the weekday of that date.
Sample input:
Enter a date: 27/04/2017
Enter the 1st day of that month: Saturday
Sample output:
Day of the date is Thursday
5|Page
COMPUTER PROJECT
6|Page
COMPUTER PROJECT
7|Page
COMPUTER PROJECT
3. Write a program in java to input a date and check whether it is a palindromic date.
Sample input:
Enter a date: 10/02/2001
Sample output:
The date is a palindromic date
8|Page
COMPUTER PROJECT
9|Page
COMPUTER PROJECT
10 | P a g e
COMPUTER PROJECT
4. Write a program in java to accept year, month, and the weekday’s name of the 1 st day of that
month. Generate its calendar in calendar format week starting with Monday.
Sample input:
Enter a year: 2017
Enter a month: June
Enter 1st day of the month: Thursday
Sample output:
June 2017
M T W TH F S S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
11 | P a g e
COMPUTER PROJECT
12 | P a g e
COMPUTER PROJECT
13 | P a g e
COMPUTER PROJECT
14 | P a g e
COMPUTER PROJECT
5. Write a program in java to accept a day number (between 1 to 366), year (4 digits) to generate
and display the corresponding date. The program further accepts ‘n’ (1<=n<=100) from the user
to compute and display the future date corresponding to ‘n’ days after the generated date.
Sample input:
Day number: 233
Year: 2008 Days
after (n): 17
Sample output:
20 August 2008
Days after 17 days: 6 September 2008
15 | P a g e
COMPUTER PROJECT
16 | P a g e
COMPUTER PROJECT
17 | P a g e
COMPUTER PROJECT
18 | P a g e
COMPUTER PROJECT
6. Design a program which accept a date of birth in dd/mm/yyyy format. Check whether the date
is a valid date or not. Also display the birth number i.e., 1,2,3,4,5,6,7,8,9,11
Sample Input:
Enter a date: 25/03/2005
Sample Output:
25/03/2005 is a valid date.
The birth number is 8 ( 2+5+0+3+2+0+0+5 = 17, 1+7=8)
19 | P a g e
COMPUTER PROJECT
20 | P a g e
COMPUTER PROJECT
21 | P a g e
COMPUTER PROJECT
22 | P a g e
COMPUTER PROJECT
7. Write a program to accept 2 dates in the string format dd/mm/yyyy and find the
difference in days between the 2 dates.
Sample Input:
Enter Date 1: 20/12/2012
Enter Date 2: 11/02/2013
Sample Output:
Difference = 54 days
23 | P a g e
COMPUTER PROJECT
24 | P a g e
COMPUTER PROJECT
25 | P a g e
COMPUTER PROJECT
8. A Vampire number is a composite natural number with an even number of digits that can be
factored into two natural numbers each with half as many digits as the original number and not
both with trailing zeros, where the two factors contain precisely all the digits of the original
number, in any order of counting multiplicity.
Example: 1260 = 21 x 60 (where, 21 and 60 contain precisely all the digits of the number )
Thus, 1260 is a Vampire number.
Accept two positive integers m and n, where m is less than n and the values of both ‘m’ and ‘n’
must be greater than or equal to 1000 and less than or equal to 9999 as user input. Display all
Vampire numbers that are in the range between m and n (both inclusive) and output them along
with the frequency, in the format specified below:
Test your program for the following data and some random data.
Example 1
INPUT: m = 1002 n = 1640
OUTPUT: THE VAMPIRE NUMBERS ARE:
1260 1395 1435 1530
FREQUENCY OF VAMPIRE NUMBER IS: 4
26 | P a g e
COMPUTER PROJECT
27 | P a g e
COMPUTER PROJECT
28 | P a g e
COMPUTER PROJECT
29 | P a g e
COMPUTER PROJECT
9. Hamming numbers are positive integer numbers whose prime factors include 2,3 and 5 only
Example:
n=6 is an hamming number as 6=2x3 .So its prime factors are limited to 2 ,3 n=8 is an hamming
number as 8=2x2x2 and it has only 2 as its prime factors
n=90 is an hamming number as 90=2x3x3x5 which has only 2,3,5 as prime factors n=14 is not a
hamming number as 14=2x7 .It has 7 as one of its prime factor
n=44 is not a hamming number as 44=2x2x11. It has 11 as one of its prime factors
Design a program to accept any positive integer number and check if it is a Hamming number or
not. Display the result with an appropriate message in the format specified below. The program
should also generate error message if a negative number is entered.
Test your program for the following data and some random data.
Example 1
INPUT: Enter any number: 3600
OUTPUT: 3600= 2 x 2 x 2 x 2 x 3 x 3 x 5 x 5 3600 IS A HAMMING NUMBER
Example 2
INPUT: Enter any number: 5832
OUTPUT: 5832= 2 x 2 x 2 x 3 x 3 x 3 x 3 x 3 x 3
5832 IS A HAMMING NUMBER
Example 3
INPUT: Enter any number: 7854
OUTPUT: 7854= 2 x 3 x 7 x 11 x 17
7854 IS NOT A HAMMING NUMBER
Example 4
INPUT: Enter a number: -120
OUTPUT: NEGATIVE NUMBER ENTERED. INVALID INPUT
30 | P a g e
COMPUTER PROJECT
31 | P a g e
COMPUTER PROJECT
10. Lucky numbers are a sequence of natural numbers that remain after removing second, third,
fourth, fifth and so on numbers respectively from a sequence of consecutive natural numbers.
32 | P a g e
COMPUTER PROJECT
33 | P a g e
COMPUTER PROJECT
34 | P a g e
COMPUTER PROJECT
35 | P a g e
COMPUTER PROJECT
11. A positive natural number, (for e.g. 27) can be represented as follows:
2+3+4+5+6+7
8 + 9 + 10
13 + 14 where every row represents a combination of consecutive natural numbers, which add
up to 27. Write a program, which inputs a positive natural number N and prints the possible
consecutive number combinations, which when added give, N.
Test your program for the following data and some random data.
Example 1
INPUT: N=9
OUTPUT: 4+5
2 +3+4
Example 2
INPUT: N=15
OUTPUT: 7+8
1+2+3+4+5
4+5+6
36 | P a g e
COMPUTER PROJECT
37 | P a g e
COMPUTER PROJECT
12. Write a program in java to accept a number and check whether it is a kaprekar number or not.
A positive whole number ‘n’ that has ‘d’ number of digits is squared and split into two pieces, a
38 | P a g e
COMPUTER PROJECT
right-hand piece that has ‘d’ digits and a left-hand piece that has remaining ‘d’ or ‘d-1’ digits. If
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 ……..
Example 1: 9
92 = 81, right-hand piece of 81 = 1 and left hand piece of 81 = 8
Sum = 1 + 8 = 9, i.e. equal to the number. Hence, 9 is a Kaprekar number.
Example 2: 45
452 = 2025, right-hand piece of 2025 = 25 and left hand piece of 2025 = 20 Sum
= 25 + 20 = 45, i.e. equal to the number. Hence, 45 is a Kaprekar number.
Example 3: 297
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. Hence, 297 is a Kaprekar number.
39 | P a g e
COMPUTER PROJECT
40 | P a g e
COMPUTER PROJECT
41 | P a g e
COMPUTER PROJECT
13. A MOBIUS function M(N) returns the value -1 or 0 or 1 for a natural number (N) by the
following conditions are defined :
When,
M ( N ) = 1 if N=1.
M ( N ) = 0 if any prime factor of N is contained more than once.
M ( N ) = ( -1 ) P if N is the product of ‘P’ distinct prime factors.
Write a program to accept a positive natural number (N) and display the MOBIUS result with
proper message.
Design your program which will enable the output in the format given below:
Sample 1
INPUT:78
OUTPUT: 78 = 2 x 3 x 13
NUMBER OF DISTINCT PRIME FACTORS = 3
M(78) = -1
Sample 2
INPUT:34
OUTPUT: 34 = 2 x 17
NUMBER OF DISTINCT PRIME FACTORS = 2
M(34) = 1
Sample 3
INPUT:12
OUTPUT: 12 = 2 x 2 x 3
DUPLICATE PRIME FACTORS
M(12) = 0
42 | P a g e
COMPUTER PROJECT
43 | P a g e
COMPUTER PROJECT
44 | P a g e
COMPUTER PROJECT
45 | P a g e
COMPUTER PROJECT
14. Write a program in java to accept a number and check whether it is a keith number or not.
A Keith Number is an integer N with ‘d’ digits with the following property:
If a Fibonacci-like sequence (in which each term in the sequence is the sum of the ‘d’ previous
terms) is formed, with the first ‘d’ terms being the decimal digits of the number N, then N
itself occurs as a term in the sequence.
For example, 197 is a Keith number since it generates the sequence
1, 9, 7, 17, 33, 57, 107, 197, ………..
Some keith numbers are: 14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537……………
46 | P a g e
COMPUTER PROJECT
47 | P a g e
COMPUTER PROJECT
48 | P a g e
COMPUTER PROJECT
49 | P a g e
COMPUTER PROJECT
50 | P a g e
COMPUTER PROJECT
51 | P a g e
COMPUTER PROJECT
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! Ubjnerlbh?
Example 2
INPUT :
You
OUTPUT :
INVALID LENGTH
52 | P a g e
COMPUTER PROJECT
53 | P a g e
COMPUTER PROJECT
54 | P a g e
COMPUTER PROJECT
17. Write a program in java to accept two words and check whether they are anagram or not.
The words that are made with the combinations of the letters present in the original word are
called anagram.
Example: FLOW and WOLF are anagram words.
55 | P a g e
COMPUTER PROJECT
56 | P a g e
COMPUTER PROJECT
57 | P a g e
COMPUTER PROJECT
18. 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.
(a) Find the number of words beginning and ending with a vowel.
(b) 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
58 | P a g e
COMPUTER PROJECT
59 | P a g e
COMPUTER PROJECT
19. A snowball string is a sentence where each word is arranged in ascending order of their length
and is also consecutive.
60 | P a g e
COMPUTER PROJECT
61 | P a g e
COMPUTER PROJECT
62 | P a g e
COMPUTER PROJECT
20. A unique-digit integer is a positive integer (without leading zeros) with no duplicate digits. For
example 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not.
63 | P a g e
COMPUTER PROJECT
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
required to output the number of unique-digit integers in the specified range along with their
values in the format specified below:
Test your program for the following data and some random data.
Example 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
64 | P a g e
COMPUTER PROJECT
65 | P a g e
COMPUTER PROJECT
21. Write a program to accept a sentence which may be terminated by either ‘.’ , ‘?’ or ‘!’ only. The
words may be separated by a single blank spaces and are in UPPER CASE.
66 | P a g e
COMPUTER PROJECT
67 | P a g e
COMPUTER PROJECT
68 | P a g e
COMPUTER PROJECT
69 | P a g e
COMPUTER PROJECT
70 | P a g e
COMPUTER PROJECT
22. 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
71 | P a g e
COMPUTER PROJECT
72 | P a g e
COMPUTER PROJECT
73 | P a g e
COMPUTER PROJECT
23. Write a program in java to accept a decimal number and convert it into its hexadecimal
equivalent.
Sample input:
Enter a decimal number: 764
Sample output:
Hexadecimal equivalent is 2FC
74 | P a g e
COMPUTER PROJECT
75 | P a g e
COMPUTER PROJECT
76 | P a g e
COMPUTER PROJECT
24. Write a program in java to accept a number and check whether it is a smith number or not. 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)
Sample input:
Enter a number: 666
Sample output:
666 is a smith number
77 | P a g e
COMPUTER PROJECT
78 | P a g e
COMPUTER PROJECT
79 | P a g e
COMPUTER PROJECT
25. Write a program in java to accept a number from the user & check whether it’s a emirp number
or not.
A number is said to be emirp if the number itself and its reverse are prime.
Sample input:
Enter a number: 31
Sample output:
31 is an emirp number.
80 | P a g e
COMPUTER PROJECT
81 | P a g e
COMPUTER PROJECT
82 | P a g e
COMPUTER PROJECT
26. Write a program in java to accept a number and check whether it is a happy number or not. A
number is said to be a Happy number if the sum of the square of the digits are calculated till a
single digit is obtained by recursively adding the sum of the square of the digits. If the single
digit comes to be 1 then the number is a Happy number.
Example:
28 = (2)2 + (8)2 = 4 + 64 = 68
68 = (6)2 + (8)2 = 36 + 64 = 100 100 =
(1)2 + (0)2 + (0)2 = 1 + 0 + 0 = 1
Sample input:
Enter a number: 28
Sample output:
28 is a happy number
83 | P a g e
COMPUTER PROJECT
84 | P a g e
COMPUTER PROJECT
27. Write a program in java to accept a range and display all Narcissistic number till the range. A
narcissistic number is a number that is the sum of its own digits each raised to the power of the
number of digits. (1634 = 14 + 64 + 34 + 44)
Sample input:
Enter a range: 1000
Sample output:
The Narcissistic numbers are:
1 153 370 371 407
85 | P a g e
COMPUTER PROJECT
86 | P a g e
COMPUTER PROJECT
87 | P a g e
COMPUTER PROJECT
88 | P a g e
COMPUTER PROJECT
29. Write a program in java to print ‘n’ terms of automorphic number. ( n is taken from the user)
An automorphic number is a number which is present in the last digit(s) of its square.
89 | P a g e
COMPUTER PROJECT
Sample input:
Enter no. of terms: 6
Sample output:
Automorphic numbers are:
1 5 6 25 76 376
90 | P a g e
COMPUTER PROJECT
91 | P a g e
COMPUTER PROJECT
92 | P a g e
COMPUTER PROJECT
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
93 | P a g e
COMPUTER PROJECT
94 | P a g e
COMPUTER PROJECT
95 | P a g e
COMPUTER PROJECT
96 | P a g e
COMPUTER PROJECT
97 | P a g e
COMPUTER PROJECT
98 | P a g e
COMPUTER PROJECT
99 | P a g e
COMPUTER PROJECT
32. Write a program to declare a square matrix A [ ][ ] of order ‘n’. Allow the user to input positive
integers into this matrix. Perform the following tasks on the matrix:
(i) Output the original matrix.
(ii) Find the SADDLE POINT for the matrix. If the matrix has no saddle point, output the message
“NO SADDLE POINT”.
A saddle point is an element of the matrix such that it is the minimum element for the row to
which it belongs and the maximum element for the column to which it belongs. Saddle point
for a given matrix is always unique.
Example: In the Matrix
456
789
513
Saddle point = 7 because it is the minimum element of row 2 and maximum element of column
1
100 | P a g e
COMPUTER PROJECT
101 | P a g e
COMPUTER PROJECT
102 | P a g e
COMPUTER PROJECT
103 | P a g e
COMPUTER PROJECT
33. 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 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) Rotate the matrix 90° clockwise as shown below:
(c) Find the sum of the elements of the four corners of the matrix.
Sample input:
M=3
3 4 9
2 5 8
1 6 7
Sample 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
104 | P a g e
COMPUTER PROJECT
105 | P a g e
COMPUTER PROJECT
106 | P a g e
COMPUTER PROJECT
34. A square matrix is said to be a Magic Square, if the sum of each row, each column and each
diagonal is same. Write a program to enter an integer number ‘n’. Create a magic square of size
‘n*n’. Finally, print the elements of the matrix as Magic Square.
Note: n <= 5
Sample Input: Enter the size of the matrix : 4
Sample Output: The Magic Matrix of size 4×4 is:
107 | P a g e
COMPUTER PROJECT
108 | P a g e
COMPUTER PROJECT
109 | P a g e
COMPUTER PROJECT
110 | P a g e
COMPUTER PROJECT
35. Write a program to declare a square matrix A[][] of order (M x M) 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:
(a) Sort the boundary elements in descending order using any standard sorting technique and
rearrange them in the matrix.
(b) Sort the non-boundary elements in ascending order using any standard sorting technique
and rearrange them in the matrix.
(c) Calculate the sum of the diagonal elements.
(d) Display the original matrix, rearranged matrix with sorted non boundary elements, display
sorted boundary element in border, diagonal elements and sum of the diagonal elements.
Test your program with the sample data and some random data:
Example 1
111 | P a g e
COMPUTER PROJECT
112 | P a g e
COMPUTER PROJECT
113 | P a g e
COMPUTER PROJECT
114 | P a g e
COMPUTER PROJECT
115 | P a g e
COMPUTER PROJECT
116 | P a g e
COMPUTER PROJECT
117 | P a g e
COMPUTER PROJECT
118 | P a g e
COMPUTER PROJECT
36. Given a square matrix M [ ] [ ] of order ‘n’. The maximum value possible for ‘n’ is 10. Accept
three different characters from the keyboard and fill the array according to the instruction given
below.
Fill the upper and lower elements formed by the intersection of the diagonals by character 1.
Fill the left and right elements formed by the intersection of the diagonals by character 2.
Fill both the diagonals by character 3.
Output the result in format given below:
Example 1
ENTER SIZE : 4
INPUT : FIRST CHARACTER : ‘*’ SECOND
CHARACTER : ‘?’
THIRD CHARACTER : ‘#’
OUTPUT :
#**#?
##?
?##?
#**#
Example 2
ENTER SIZE : 5
INPUT : FIRST CHARACTER : ‘$’
SECOND CHARACTER : ‘!’
THIRD CHARACTER : ‘@’
OUTPUT :
@$$$@
!@$@!
!!@!!
!@$@!
@$$$@
119 | P a g e
COMPUTER PROJECT
120 | P a g e
COMPUTER PROJECT
121 | P a g e
COMPUTER PROJECT
37. A super class Bank has been defined to store the details of the customer in a bank. Define a
subclass Interest to calculate the compound interest.
The details of the members of both the classes are given below:
Class name : Bank
Data members/instance variables:
name : to store the name of the customer acc_no : integer to
store the account number principal : to store the principal
amount in decimals Methods / Member functions:
Bank( ... ) : parameterized constructor to assign values to the data members void
display( ) : to display the customer details
Class name Interest
Data members/instance variables:
rate : to store the interest rate in decimals time : to store
the time period in decimals Methods / Member functions:
Interest( ... ) : parameterized constructor to assign values to the data members
of both the classes
double calculate( ) : to calculate and return the compound interest using the formula
[ CI = P ( 1 + R/100 ) N − P] where, P is the principal, R is the
rate and N is the time
void display( ) : to display the customer details along with the compound
interest
Using the concept of inheritance, specify both the classes.
122 | P a g e