0% found this document useful (0 votes)
172 views

XII Class Assignment Programs 2023-24

The document describes 7 computer science assignment programs involving tasks like: 1) Packaging boxes into cartons of different sizes 2) Finding all odd prime number pairs that sum to a given even integer 3) Generating dates based on a day number and year, and calculating dates after a number of days 4) Checking if a number is a circular prime by testing if its digits remain prime after cyclic shifts 5) Displaying the denomination breakdown of a cash amount up to 5 digits 6) Determining Kaprekar numbers in a given range by testing if squaring a number equals the sum of its digit parts 7) Additional sample test cases and test data are provided for each program

Uploaded by

Sudhir Kumar
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)
172 views

XII Class Assignment Programs 2023-24

The document describes 7 computer science assignment programs involving tasks like: 1) Packaging boxes into cartons of different sizes 2) Finding all odd prime number pairs that sum to a given even integer 3) Generating dates based on a day number and year, and calculating dates after a number of days 4) Checking if a number is a circular prime by testing if its digits remain prime after cyclic shifts 5) Displaying the denomination breakdown of a cash amount up to 5 digits 6) Determining Kaprekar numbers in a given range by testing if squaring a number equals the sum of its digit parts 7) Additional sample test cases and test data are provided for each program

Uploaded by

Sudhir Kumar
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/ 8

ISC Computer Science Assignment

Computer Science Assignment


Session = 2023-24

Program 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 * 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.

A number is said to be prime if it has only two factors 1 and itself.

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

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 , and 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 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:

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

6
ISC Computer Science Assignment

Example 2

INPUT : 6043

OUTPUT :

SIX ZERO FOUR THREE

DENOMINATION:

1000 x 6 = 6000

20 x 2 = 40

2 x 1 = 2

1 x 1 = 1

TOTAL = 6043

TOTAL NUMBER OF NOTES = 10

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

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.

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.

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.

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

You might also like