XII Class Assignment Programs 2023-24
XII Class Assignment Programs 2023-24
Program 1
Test your program with the following data and some random data:
Example 1
INPUT:
N = 726
OUTPUT:
48 * 15 = 720
6*1=6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
Example 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
Example 3
INPUT:
N = 4296
1
ISC Computer Science Assignment
OUTPUT:
INVALID INPUT
Program 2
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:
2
ISC Computer Science Assignment
7, 23
11, 19
13, 17
Program 3
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 with the following data and some random data:
Example 1
INPUT:
DAY NUMBER: 255
YEAR: 2018
DATE AFTER (N DAYS): 22
OUTPUT:
DATE: 12TH SEPTEMBER, 2018
DATE AFTER 22 DAYS: 4TH OCTOBER, 2018
Example 2
INPUT:
DAY NUMBER: 360
YEAR: 2018
DATE AFTER (N DAYS): 45
OUTPUT:
DATE: 26TH DECEMBER, 2018
DATE AFTER 45 DAYS: 9TH FEBRUARY, 2019
Example 3
3
ISC Computer Science Assignment
INPUT:
DAY NUMBER: 500
YEAR: 2018
DATE AFTER (N DAYS): 33
OUTPUT:
DAY NUMBER OUT OF RANGE
Example 4
INPUT:
DAY NUMBER: 150
YEAR: 2018
DATE AFTER (N DAYS): 330
OUTPUT:
DATE AFTER (N DAYS) OUT OF RANGE
Example 3
INPUT:
N = 17
OUTPUT:
INVALID INPUT. NUMBER IS ODD.
Example 4
INPUT:
N = 126
OUTPUT:
INVALID INPUT. NUMBER OUT OF RANGE.
4
ISC Computer Science Assignment
Program 5
A Circular Prime is a prime number that remains prime under cyclic shifts of its
digits. When the leftmost digit is removed and replaced at the end of the remaining
string of digits, the generated number is still prime. The process is repeated until the
original number is reached again.
Example:
131
311
113
Hence, 131 is a circular prime.
Accept a positive number N and check whether it is a circular prime or not. The new
numbers formed after the shifting of the digits should also be displayed.
Test your program with the following data and some random data:
Example 1
INPUT:
N = 197
OUTPUT:
197
971
719
197 IS A CIRCULAR PRIME.
Example 2
INPUT:
N = 1193
OUTPUT:
1193
1931
9311
3119
1193 IS A CIRCULAR PRIME.
Example 3
INPUT:
N = 29
OUTPUT:
29
92
29 IS NOT A CIRCULAR PRIME.
5
ISC Computer Science Assignment
Program 6
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 the 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:
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
6
ISC Computer Science Assignment
Example 2
INPUT : 6043
OUTPUT :
DENOMINATION:
1000 x 6 = 6000
20 x 2 = 40
2 x 1 = 2
1 x 1 = 1
TOTAL = 6043
Example 3
INPUT : 235001
OUTPUT:
INVALID AMOUNT
7
ISC Computer Science Assignment
Program 7
A positive whole number ‘n’ that has ‘d’ number of digits is squared and split into
two pieces, a 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
Example 2: 45
452 = 2025, right-hand piece of 2025 = 25 and left hand piece of 2025 = 20
Example 3: 297
2972 = 88209, right-hand piece of 88209 = 209 and left hand piece of 88209 = 88
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, 99, 297, 703, 999
FREQUENCY OF KAPREKAR NUMBERS IS: 8