XI Assignment QUESTIONS

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Programming Assignments (Class – XI)

Students are expected to do a minimum of 15 assignments throughout the year.

Assignment 1: (DONE)
Write a program to accept the numbers of rows and columns of matrix from the user to create a
two-dimensional array using the given input. Fill the matrix up with user given input then perform
the following operations:
(i) Display the original matrix.
(ii) Find and display the sum of each row and each column, separately.
(iii) Find and display the absolute difference between the sum of left diagonal and right diagonal
when number of rows and columns are same. Otherwise, display an error message.
(iv) Display the transpose matrix.

Assignment 2: (DONE)
Write a program that accepts a range of numbers from the user and displays the Composite-Magic
numbers present within that range along with their frequency.
A composite magic number is a positive integer which is composite as well as a magic number.
Composite number: A composite number is a number that has more than two factors.
For example: = 6 is a Composite number as it is a multiplication of two positive integers 2 and 3.
Magic number: A magic number is a number in which the eventual sum of the digits is equal to 1.
For example: = Considering the number 118. Sum of the digits present in 118 is 10 (1+1+8). Sum of
the digits present in 10 is 1 (1+0). Since, the eventual sum of 118 is equal to 1. It is a Magic Number.
Input: =
Enter the range:
100
150
Output: =
Composite Magic number(s) withing the given range are/is:
100, 118, 136, 145,
Frequency: 4

Assignment 3:
Write a program to accept a sentence from the user in uppercase and rearrange the letters present
in each of the words in ascending order. (Must be done using StringTokenizer).
Input: =
Enter a sentence:
IT IS A RAINY DAY.
Output: =
The new sentence is:
IT IS A AINRY ADY
Assignment 4:
Write a program to accept a sentence from the user in uppercase and encrypt the sentence using
the Ceasar-Cipher Encryption Technique with a shift of 13.
Input: =
Enter a sentence:
I WILL NOT GO TO SCHOOL TODAY
Output: =
Encrypted sentence:
V JVYY ABG TB GB FPUBBY GBQNL

Assignment 5:
Write a program to accept a sentence from the user and find the potential of each word. Take the
cases of each letter into consideration. Create a separate function that takes in individual words as
parameters and returns the potentials.
Potential of a word is found by adding ASCII values of the alphabets.
Input: =
Enter a sentence:
How Do You Do?
Output: =
Potential of How is 302
Potential of Do is 179
Potential of You is 317
Potential of Do? is 242

Assignment 6: (DONE)
Write a program to declare a square matrix M[n][n] of order ‘n’ where ‘n’ must be greater than 3
and less than 10. Allow the user to accept 3 different characters from the keyboard and fill the array
according to the instruction given below:
Input: =
n=4
FIRST CHARACTER: @
SECOND CHARACTER: ?
THIRD CHARACTER: #
Output: =
@? ?@
? # # ?
? # # ?
@? ?@

Assignment 7:
Write a program that accepts a value from the user and produces a new number so as the odd
digits are decreased by 1 and even digits are increased by 1.
For example, if the user input is 2796041, then the output of the program will be 3687132.
A class STYLE has been designed to perform the following task. Some of the member of the class are
given below.
Class name : STYLE
Data Members/Instance variables :
int W : Stores the user input.
int N : Stores the newly produced number.
Member Functions :
STYLE() : Constructor to initialize data members.
void input() : Accept value from the user.
void display() : Print the member data with proper message.
void change() : Write a method to create a new number by changing the accepted number
following the condition given.
Create the class STYLE. Define the main() to create an object and call the functions accordingly to
complete the task.

Assignment 8: (DONE)
Write a program to accept the numbers of rows and columns of matrix from the user to create a
two-dimensional array using the given input. Fill the matrix up with user given inputs. Apply any one
of the sorting techniques to sort the values of each row in descending order.
Input: =
Enter the number of rows: 2
Enter the number of columns: 4
Enter values in a 2X4 matrix:
45
89
12
78
12
56
33
77
Output: =
--Original Matrix—
45 89 12 78
12 56 33 77
--Sorted Matrix—
89 78 45 12
77 56 33 12

Assignment 9: (DONE)
Write a program to accept an even number(N>9 and N<50). Display whether it is a Goldbach
Number or not.
Goldbach number: A positive even integer that can be expressed as the sum of two odd primes.
Sample Input 1:
Input: =
Enter a number:32
Output: =
32 is a Goldbach Number
Sample Input 2:
Input: =
Enter a number:25
Output: =
25 not is a Goldbach Number
Sample Input 2:
Input: =
Enter a number:60
Output: =
INVALID INPUT.

Assignment 10: (DONE)


Write a program that accepts two values from the user and produces a concatenated version of the
two inputted values.
For example, if the user inputs are 987 and 8745, then the output of the program will be 9878745.
A class MERGER has been designed to perform the following task. Some of the member of the class
are given below.
Class name : MERGER
Data Members/Instance variables :
long n1 : Stores the first user input.
long n2 : Stores the second user input.
long mergedNum : Stores the merged value.
Member Functions :
MERGER() : Constructor to initialize data members.
void readNum() : Accept the values from the user.
void joinNum() : Concatenates the user inputted values .
void show() : Displays the user inputted values along with the new merged value.
Create the class MERGER. Define the main() to create an object and call the functions accordingly
to complete the task.

Assignment 11: (DONE)


Write a program that accepts a word from the user in lowercase and produces a new word such
that the consonants present in the word is shifted to the front and changed into uppercase and the
remaining vowels from the world are shifted towards the back.
For example, if the user inputs the word ‘sunny’, the output of the program will be ‘SNNYu’.
A class ConsChange has been designed to perform the following task. Some of the member of the
class are given below.
Class name : ConsChange
Data Members/Instance variables :
String word : Stores the user input in lowercase.
int len : Stores the length of the word.
Member Functions :
ConsChange() : Default Constructor.
void readWord() : Accept the word from the user.
void shiftCons() : Shifts the consonants to the front.
void changeWord() : Change the consonants to uppercase.
void show() : Displays the original word along with the new word.
Create the class ConsChange. Define the main() to create an object and call the functions
accordingly to complete the task.

Assignment 12:
The co-ordinates of a point P on a two-dimensional plane can be represented by P(x, y) with x as the
x-coordinate and y as the y-coordinate. The coordinates of the midpoint of two points P1(x1, y1)
and P2(x2, y2) can be calculated as p(x, y) where:
x 1+ x 2 y 1+ y 2
x= ∧y=
2 2
Design a class Point with the following details:
Class name : Point
Data Members/Instance variables :
X1 : Stores the x1 coordinate.
Y1 : Stores the y1 coordinate.
X2 : Stores the x2 coordinate.
Y2 : Stores the y2 coordinate.
Member Functions :
Point() : Default Constructor.
void readpoint() : Accept the coordinates x and y of a point.
int midpoint(int x1, int x2, int y1,
int y2) : Calculates and returns the midpoint of A and B.
void display() : Displays the user input co-ordinates along with the co-ordinates of the midpoint.
Specify the class Point, giving details of the constructor and the member functions. Write the
main() to create an object of the class and call the functions, accordingly.

Assignment 13: (DONE)


Write a program that accepts a word from the user and encodes it into Piglatin.
To translate a word into a Piglatin word, first convert the word into uppercase and then place the
first vowel of the original word as the start of the new word along with the remaining alphabets.
The alphabets present before the vowel being shifted towards the end followed by “AY”.
Sample Input 1: =
Enter the word: London
Output 1: = ONDONLAY
Sample Input 2: =
Enter the word: Olympics
Sample Output 2: = OLYMPICSAY

Assignment 14:
Write a program to covert a binary number to its equivalent decimal number and vice versa
depending upon the user's choice. Create recursive functions toBinary() and toDecimal() for the
purpose.
Assignment 15: (DONE)
A happy number is a number in which the eventual sum of the square of the digits of the number is
equal to 1.
For Example:
28 = (2)2 + (8)2 = 4 + 64 = 68
68 = (6)2 + (8)2 = 36 + 64 = 100
100 = (1)2 + (0)2 + (0)2 = 1 + 0 + 0 = 1
Hence, 28 is a happy number.
Example 2:
12 = (1)2 + (2)2 = 1 + 4 = 5
Hence, 12 is NOT a happy number.
Design a class Happy to check if a given number is a happy number. Some of the members of the
class are given below:
Class name : Happy
Data members/Instance variables :
Num : Stores the number.
Member Functions :
Happy() : Default Constructor.
void getNum() : Accept the number for checking from the user.
int sum_of_squares(int x) : Returns the sum of the square of the digits of
the number x, using recursive technique.
void isHappy() : Checks of the given number is a happy number by
calling the function sum_of_squares(int) and
displays an appropriate message.
Specify the class Happy giving details of the constructor( ), void getNum(), int sum_of_squares(int)
and void isHappy( ). Define the main() function to create an object and call the methods to check
for happy number.

You might also like