0% found this document useful (0 votes)
20 views5 pages

Assignment 1

Uploaded by

prithvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Assignment 1

Uploaded by

prithvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Std.

XII
Assignment 1
Submission Date: 22nd April 2024
1.
Caesar Cipher is an encryption technique which is implemented as ROT13 ('rotate by 13 places'). It is a
simple letter substitution cipher that replaces a letter with the letter 13 places after it in the alphabets, with
the other characters remaining unchanged.
ROT13

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! Ubj ner lbh?
Example 2
INPUT:
Encryption helps to secure data.
OUTPUT:
The cipher text is:
Rapelcgvba urycf gb frpher qngn.
Example 3
INPUT:
You
OUTPUT:
INVALID LENGTH
2.
The encryption of letters are to be done as follows:
A=1
B=2
C=3...
Z = 26
The potential of a word is found by adding the encrypted value of the letters.
Example: KITE
Potential = 11 + 9 + 20 + 5 = 45
Accept a sentence which is terminated by either " . " , " ? " or " ! ". Each word of sentence is separated by
single space. Decode the words according to their potential and arrange them in alphabetical order increasing
order of their potential. Output the result in the format given below:
Example 1
Input:
THE SKY IS THE LIMIT.
Potential:
THE = 33
SKY = 55
IS = 28
THE = 33
LIMIT = 63
Output:
IS THE THE SKY LIMIT
Example 2
Input:
LOOK BEFORE YOU LEAP.
Potential:
LOOK = 53
BEFORE = 51
YOU = 61
LEAP = 34
Output:
LEAP BEFORE LOOK YOU
3.
A class Composite contains a two dimensional array of order [m x n]. The maximum value possible for both ‘m’
and ‘n’ is 20. Design a class Composite to fill the array with the first (m x n) composite numbers in column wise.
The details of the members of the class are given below:
class name : Composite
Data members/instance variables:
arr[ ] [ ] : stores the composite numbers column wise
m : integer to store the number of rows
n : integer to store the number of columns
Member functions/methods:
Composite(int mm, int nn ) : to initialize the size of the matrix m=mm and n=nn
int isComposite( int p ) : returns 1 if number is composite otherwise returns 0
void fill ( ) : to fill the elements of the array with the first (m × n) composite numbers in
column wise
void display( ) : displays the array in a matrix form
Specify the class Composite giving details of the constructor(int,int), int isComposite(int), void fill( ) and void
display( ). Define a main( ) function to create an object and call the functions accordingly to enable the task.

4.
A class Capital has been defined to check whether a sentence has words beginning with a capital letter or not.
Some of the members of the class are given below:
class name : Capital
Data member/instance variable:
sent : to store a sentence
freq : stores the frequency of words beginning with a capital letter
Member functions/methods:
Capital( ) : default constructor
void input() : to accept the sentence
boolean isCap(String w) : checks and returns true if word begins with a capital letter, otherwise returns
false
void display () : displays the sentence along with the frequency of the words beginning with a
capital letter
Specify the class Capital, giving the details of the constructor( ), void input( ), boolean isCap(String) and void
display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task
5.
An Evil number is a positive whole number which has even number of 1's in its binary equivalent. Example:
Binary equivalent of 9 is 1001, which contains even number of 1's. A few evil numbers are 3, 5, 6, 9.... Design
a program to accept a positive whole number and find the binary equivalent of the number and count the
number of 1's in it and display whether it is a Evil number or not with an appropriate message. Output the
result in format given below:
Example 1
Input: 15
Binary Equivalent: 1111
No. of 1's: 4
Output: Evil Number

Example 2
Input: 26
Binary Equivalent: 11010
No. of 1's: 3
Output: Not an Evil Number
6.
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:
7, 23
11, 19
13, 17
Example 3
INPUT:
N = 17
OUTPUT:
INVALID INPUT. NUMBER IS ODD.
Example 4
INPUT:
N = 126
OUTPUT:
INVALID INPUT. NUMBER OUT OF RANGE.

You might also like