CLASS : XII
SUB: COMPUTER SCIENCE
1. A prime- Adam integer is a positive integer (without leading zeros) which is a prime as
well as an Adam-number. [2020]
Adam number: The Square of a number and the square of its reverse are reverse to each other.
Ex: if n=13 and reverse of n=31, then
(13)2 =169
(31)2=961 which is reverse of 169
Thus, 13, is an Adam number.
Accept two positive integers m and n, where m is less than n as user input. Display all
prime-Adam integers that are in range between m and n (both inclusive) and output them along
with the frequency, in the following format below:
Ex: INPUT: m=5
n=100
OUTPUT: THE PRIME-ADAM INTEGERS ARE:
11 13 31
FREQUENCY IS: 3
2. Write a program to declare a matrix A[][] of order (M×N) where ‘M’ is the number of
rows and N is the number of columns such that the value of M must be greater than 0 and less
than 10 and the value of N must be greater than 2 and less than 6. Allow the user to input digits
(0-7) only at each location, such that each row represents an octal number.
Ex:
3. Write a program to declare a 1 D 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: [2019]
a) Sort the elements of the single dimensional array in ascending order using any standard
sorting technique and display the sorted elements.
b) Fill the square matrix b[][] in the following format.
If tha array a[]= {5,2,1,8} the 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
c) Display the filled matrix in the above format.
4. A company manufactures packing cartons in four sizes i.e. cartons in accommodate 6
boxes, 12 boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be
packed (N) by user (maximum up to 1000 boxes) and display the break-up of the cartons used in
descending order of the capacity (i.e. preference should be given to highest capacity available,
, Ex1:
INPUT: N=726
OUTPUT: 48 * 15 =720
6 *1 = 6
Remaining boxes: =0
Total number of boxes: =726
Total number of cartons: =16
Ex 2:
INPUT: N=140
OUTPUT: 48 * 2 = 96
24 *1 = 24
12*1 = 12
6*1 =6
Remaining boxes 2 * 1 = 2
Total number of boxes =140
Total number of cartons = 6
5. A Goldbach number is a positive even integer that can be expressed as the sum of two odd
primes.(All even integers greater than 4 are Goldbach numbers.) [2018]
Ex: 6=3 +3
10=3 + 7
10= 5 + 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’.
Ex: INPUT: N=30
OUTPUT: PRIME PAIRS ARE: 7, 23
11, 19
13, 17
6. Give two positive numbers M and N, such that M is between 100 and 1000 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=10 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 validity of the inputs and display an
appropriate message for an invalid input. [2015]
EX: Input: M=100