 1. Input a number to check for prime number or perfect number. Design a program to create a class perfect having two functions, one as prime(int a) another as perfect(int b)[A prime number has only two factors, 1 and itself.

A perfect numbers sum of factors is equal to the number. ]

Example 1:

INPUT

Enter number

7

OUTPUT:

It is a prime number

It is not a perfect number.

Example 2:

INPUT

Enter number

6

OUTPUT:

It is not a prime number

It is a perfect number.

2. Design a program to accept any number and print its Fibonacci series, where the number entered should be between 10 to 50 if the entered number is not inside the range then print relevant message.

Example 1:

INPUT

Enter number between 10 to 50

15

OUTPUT:

1, 1, 2, 3, 5, 8, 13

Example 2:

INPUT

Enter number

52

OUTPUT:

Invalid output

3. Design a program to create an array of integers, size should be entered by the user(between 5 to 20). And sort the array in ascending order. with any sorting technique [Bubble sort or selection sort]

Example 1:

INPUT

Enter number between 5 to 20

5

Enter numbers

23, 4, 58,32, 100

OUTPUT:

Array before sorting

23, 4, 58, 32, 100

Array after sorting

4,23,32,58,100

Example 2:

INPUT

Enter number between 5 to 20

32

OUTPUT:

Invalid Input

4. The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10 digit code. The ISBN is legal if :

1 x digit1  + 2 x digit2 + 3 x digit4 + 4 x digit4  + 5 x digit5  + 6 x digit6  + 7 x digit7 + 8 x digit8  + 9 x digit9  +

10 x digit10 is divisible by 11.

Example: For an ISBN 1401601499

Sum = 1 x 1 + 2 x 4 + 3 x 0 + 4 x 1 + 5 x 6+ 6 x 0+ 7 x 1+ 8 x 4 + 9 x 9 + 10 x 9 = 253 which is divisible by 11.

Write a program to :

i)            Input the ISBN code as a 10 – digit integer.

ii)           If the ISBN is not a 10 digit integer, output the message, “Illegal ISBN” and terminate the program.

iii)          If the number is 10-digit, extract the digits of the number and compute the sum as explained above. If the sum is divisible by 11, output the message, “Legal ISBN”. If the sum is not divisible by 11, output the message, “Illegal ISBN”.

SHARE
Previous articleICSE practical sample paper 3
Next articleBinary Search