Class 11 & 12 Practical Problems Set 1


1. A string is decoded by converting each first letter of each word in upper case and other in lower case and reversing and printing column wise in the following format write a programme to input any string in mix case separated by single blank space and decode in below format

Sample Input 
Inputted String : ThEquicKBrowNFOxJuMPED
Output :
   d      x     n    k    e 
e         o     w    c    h 
p         F     o    i    T
m               r    u    
u               B    Q 
   J   
                    
2. A set is a collection in which there is no duplication of elements a multi set is a collection in which elements can be duplicate for example
S = {1,2,3,4} is a set with integer elements.
while ms = {1,2,3,1,3} is a multiset with integers elements.
Following are some member function of class multiset which defines multi set with integer elements
Class Name  Set
Data members / instance variables
Intarr[]      integers array of size n
Int n [size]
Member Functions / methods:
Set() - Constructor to assign zero to n
Set(int nn) - Constructor to assign n = nn
intisset(set s) - returns 1(one) if the multiset object is a set and 0(zero) otherwise.
Set intersection(Set s1, Set s2)  returns intersection elements of s1,s2 assume that s1 and s2 are sets.
Void displaylist() - to display the intersection elements if both are set. Else display "multiset".
Also write main().
    
3. Design a program which accepts your accepts your dob in dd mm yyyy format. Check whether the date entered is a valid date or not. If it is valid, display "VALID DATE". Also compute and display the day number of the year for the dob And the date in words as given example if it is valid display invalidate and then terminate the program.
 EXAMPLE : 1
 INPUT : Enter your date in dd mm yyyy format
 05
 01
 2013
 OUTPUT :  VALID DATE  5
           5th January 2013

EXAMPLE : 2
INPUT : Enter Your DOB in dd mm yyyy
03
04
2010
OUTPUT : VALID DATE 
         93
         3rd April 2013
                        
4. A class staff is declared with the following details
Class name staff
Data members :
Code_num    int to store staff code number
Sname       To store staff's name
Basic       To store basic salary
Member Functions :
Staff() -  Constructor
void input() -  To accept the values
void printdata()  -  To print values

Another class Overtime is declared as
Class Name Overtime
Data members 
ndays :  To store the number of days worked
ex_hrs : To store the number of hours worked per day
rate : Rate per hour
Member Functions 
Overtime (int n, double r, int h)  Constructor to assign n to ndays , 
r to rate anf h to ex_hrs
Double calculate() : to calculate the total salary(Number of days worked * rate per hour 
* number of hours worked per day + basic salary) and total salary.
void show_salary()   To display number of days worked rate and total salary.
Using the concept of inheritance define the above classes and all the 
functions in them the main function need not to be written.

                    
5. NIC institute's Resource manager has decided to network the computer resources like printer storagemediathat minimum resource and maximum sharing could be availedaccordingly printers are linked to a centralised system and the printing jobs are done on a first come first served basis only this is like the first person's printing job will get done first and the next person job will Bdone as the next job in the list and so on in order to avoid collision the restriction is that no more than 20 printing jobs can be added.
Define a class PrintJob with the following details:
Class name       PrintJob

Data members :

job[] Array of integers to hold the printing jobs
Newjob To add a new printing job into the array
Capacity  maximum capacity of the integer array
Front To point to the index of the Front
Rear To point to the index of the last

Member Functions 

PrintJobs()   Constructor to initialise the data member capacity 20 
Front = Rear = 1 and Call the function createJob()
voidcreateJob() To create an array to hold the printing PrintJobs
voidaddJob()   Adds the new printing job to the end of the last printing job if 
possible otherwise displays the message print job is full cannot add anymore
voidremoveJob() - Remove the printing job from the front if the printing job 
is not empty otherwise displays the message paint job is empty

Also write the main function



                    
6. Define a class RecursivePower with the following specification
Class Name    RecursivePower
Data members 
int pow,k,l
Member Functions
RecursivePower() -  Constructed to initialise power= 0
void input() - to input value in k and l
intpowerof(int k , int l) Returns power of k to l recursively
void setpower()  Sets data member power=k to power l
void display   display the data member power

Also write main function
                    
7. Define a class PrintPrime with the following specification
Class Name    PrintPrime
Data members 
String str , int c
Member Functions

void getdata() - to input string without spaces
void printp(int p , int q)  Print only prime location character in one string recursively.

Eg i/p PROGRAM
   o/p OGA

Also write main function
                                            
8. Class Binary contains an array of an integers (n<=100) that are already arranged in ascending order the subscript of the array elements vary from 0 to n-1 the data members and members function are as follows
Class Name    Binary
Data members 
a[] int array of 100 elements
n Size of the Array
l Location of lower bound
u Locations of upper bound

Member Functions

Binary(int num)  Constructed to initialise n =  num And other instance variables
void readdata() - To fill array elements in ascending order
int binary_search(int v) -   Returns the location of the value v after searching the list by 
using binary search technique using recursion, the function returns -1 if the number is not present in the list.
          
Also write main function
9. Define a class Trr with the following data members
int arr[3][3] and following functions
void input() - To input a 3x3 matrix
Transpose() To return transfers of matrix arr[][]
Trrproduct(Trr M) - To return the product of current and the transposed matrix M
void display() - To display the matrix it transpose and the product in the following format:

1 3 1     1 2 9     11  21  21
2 4 7  x  3 4 2  =  21  69  68
9 2 6     1 7 6     21  68  121
                    
10. Define Class point with the following details
Class Name    Point
Data members 
A[][] double dimensional array
R Integer to store row size
C Integer to store column size

Member Functions

point(int p , int q)  Constructed to assign p to R and q to C and create array of RXC order
void get_array() - to input a double dimensional array in the form of matrix of given rows and columns
void display_mat() -   to print the entered matrix.
int check_pseudo(int a[]) - to check and find whether elements in each row are pseudo numbers 
or not return 1 if numbers in rows are pseudo numbers else return 0
void result() - invoke check_pseudo() to find whether the numbers in each row are pseudo nnumbers or not and display result in the given format.
            
Input Matrix 
3 5 2 4
2 5 4 9 
8 6 8 7

Output
 row 1 pseudo numbers
 row 2 not pseudo numbers
 row 3 not pseudo numbers
11. Define Class Replace with the following details
Class Name    Replace
Data members 

String str, substr

Member Functions

Replace()  Constructor.
Replace(String s) - A constructor to assign s to str
void display() -   To print values of st, substr and frequency of substr in str
voidgetword(String ss) - to assign ss (it is a string no blank space) to substr
intfind_frequency() - to find frequency of substr in str and returns the frequency substr can occur in sub word also.
            
For Eg.
Str = "fox jumped on the ox
Substr ="ox"
 It should return = 2 
 Also write main().
12.
A class Numbers contains the following data members and member functions to fill the cell of N X N matrix
with the triangular numbers. [ A triangular number is formed by the addition of a consecutive sequence of
integers starting from ‘Num’].
e.g.    if Num=1 then
        1 + 2 = 3
        1 + 2 + 3 = 6
        1 + 2 + 3 + 4 = 10
        1 + 2 + 3 + 4 + 5 = 15
Therefore, 3, 6, 10, 15 etc. are triangular numbers.

Class name      :   Numbers
Data members/ instance variables:
N       :   integer to store order of matrix.
Num     :   integer to store starting value of triangular numbers.
Prev    :   integer to store last value which gave triangular number.
Arr[][] :   array to store triangular numbers in array
Member functions/methods:
Numbers(int a, int b):  constructor to assign a to N and create matrix of order N X N. Also assign Num=b
Numbers check(int n) :  to check if ‘n’ is triangular and initialize ‘n’ to Num if triangular or initialize
                        Num by next triangular greater than ‘n’ and initialize Prev with last value which 
                        gave triangular number.
void fill( )         :   to fill the boundary cells of Arr[][]by triangular number
                            beginning from ‘Num’.
void display()       :   to display the matrix Arr[].

Specify the class Numbers giving details of the functions int check(int) and void display( )
13. Write a programme to declare a matrix A[][] of order M x N where M is the number of rows and N is the number of columns such that both M and N must be greater than 2 and less than 20 allow the user to input in integers into this matrix perform the following task on the matrix display the input matrix
Find the maximum and minimum value in the matrix and display them along with their position
Sort the element of the matrix in a sending order using any standard sorting technique and rearrange them in the matrix.
INPUT
Entered values : 8,7,9,3,-2,0,4,5,1,3,6,-4
Original Matrix : 
8 7 9 3
-2 0 4 5
1 3 6 -4
largest number : 9
Row : 0
Column : 2
Smallest number : -4
Row = 2
14.
An ISBN (International Standard Book Number) is a ten digit code which uniquely identifies a book.
The first nine digits represent the group, publisher and title of the book and the last digit is 
used to check whether ISBN is correct or not.
Each of the first nine digits of the code can take a value between 0 to 9. Sometimes it is necessary 
to make the last digit equal to ten. This is done by writing the last digit of the code as X.
To verify an ISBN, calculate 10 times the first digit, plus 9 times the second digit, plus 8 times 
the third digit and so on until we add 1 time the last digit. If the final number leaves no remainder 
while divided by 11, the code is a valid ISBN

For example:

0201103311=10*0+9*2+8*0+7*1+6*1+5*0+4*3+3*3+2*1+1*1=55
This is a valid ISBN

007462542X=10*0+9*0+8*7+7*4+6*6+5*2+4*5+3*4+2*2+1*10=176
This is a valid ISBN

Similarly 0112112425 is not a valid ISBN.

Test Data:-

Input code: 0201530821
Output: Sum=99
Leaves no remainder – valid ISBN

Input code: 356680324
Output: Sum=invalid input

Input code: 0231428031
Output: Sum=122
Leaves remainder – invalid ISBN
15.
Write a program which first inputs two integers, the first between 1 and 12 (both inclusive) 
and second between 0 and 59(both inclusive) and then prints out the time they represent, in words.
Test Your program for the following data:-

SAMPLE  DATA :
INPUT :  
TIME  : 3:0 
OUTPUT : 3:00  Three O’clock    
INPUT :  
TIME  : 7:29  
OUTPUT : 7:29  Twenty Nine Minutes Past Seven   
INPUT :   6:34  
OUTPUT : 6:34  Twenty Six  Minutes To Seven     
INPUT :    TIME  : 14,60
OUTPUT : Incorrect input
                       
16.
WAP to store 'N' different numbers in SDA where 'N' is always odd. Arrange them in such a way that
the smallest element should be in the middle position, second smallest element to the left side of it, 
third smallest to the right side and so on …..
    
Input       :   71, 40, 66, 56, 19, 31, 85, 99, 23, 91, 59
Output  :   91, 71, 59, 40, 23, 19, 31, 56, 66, 85, 99


Class members are specified below:-
Class name: arrange

Data members:-
arr []  :   integer type
size    :   integer type variable to store size of array

Member Functions:-
Arrange (int n) :   parameterized constructor to initialize n to size
Void input()        :   function to input an array of specified size
Void arrange()  :   to arrange them in such a way that the smallest element should be in the middle position,
second smallest element to the left side of it, third smallest to the right hand side and so on …..  
Void dsiplay()  :   function to display the array before and after arrangement

Specify the class arrange and also write the main() function.
17.
Design a class point which contains Following:

Data members -  a 2d array, row size,col size row index, col index and other
data members as required.

Member Functions
(a) void get_array() - to input 2d array
(b) void display_mat() - to print the matrix
(c) void check_saddle()  - to find and print the saddle Entered Matrix set (a saddle point for any matrix exist in all the rows 
if and only if smallest element from each row should be greatest in the corresponding column)

Example :
3 5 7 4
1 6 4 9
2 4 7 5

The output should be saddle point is 3 
(row =0 and column = 0)

Also write the main() method


18.
A broadband provider is trying to calculate difference between the login time and logout time.  
The time is in 12 hours format. A system is designed to calculate difference (in hrs and min) and total amount in rupees. 
The charge in rupee 0.16/min

Sample input

Login time 2:35 PM
Logout time 3:35 PM

SAMPLE OUTPUT
TOTAL TIME  1 HRS 0 MIN
YOUR AMOUNT RS 9.5

SAMPLE INPUT 
LOGIN TIME 10:35 AM
LOGOUT TIME 2:50 PM
SAMPLE OUTPUT
    TOTAL TIME 4 HRS 15 MIN
YOUR AMOUNT  RS 40.8

INPUT LOGIN TIME AND LOGOUT TIME AND CALCULATE DIFFERENCE TIME AMOUNT TO BE PAID. 
TEST YOUR PROGRAM FOR ABOVE DATA. THE INPUT WILL BE IN THE ABOVR FORMAT ONLY. 
NOTE ASUME THAT DIFFERENCE BETWEEN THE TIMES CANNOT BE MORE THAN 24 HRS
19.
The computer department of the Agency of International Espionage is trying to decode intercepted 
messages. The agency’s spies have determined that the enemy encodes messages by first converting 
all characters to their ASCII values and then reversing the string.

For example, consider A_z (the underscore is just to highlight the space). The ASCII values of 
A. , z are 65, 32, 122 respectively. Concatenate them to get 6532122, then reverse this to 
get 2212356 as the code message.

Write a program which reads a coded message and decodes it. The coded message will not exceed 200 
characters. It will contain only alphabets (A …. Z, and a ….z) and spaces. ASCII values of A …Z are 
65 ...90 and those of a …z are 97 …122. Test your program for the following data and some random data.

SAMPLE DATA:

INPUT;
Encode message:
2 3 1 2 1 7 9 8 6 2 3 1 0 1 9 9 5 0 1 8 7 2 3 7 9 2 31 0 1 8 1 1 7 9 2 7

OUTPUT:
THE DECODED MESSAGE: Have a Nice Day

INPUT;
Encode message:
2 3 5 1 10 1 1 5 0 1 7 8 2 3 5 1 1 1 2 1 7 9 9 1 1 8 0 1 5 6 2 3 4 0 1 6 1 1 7 1 1 4 1 1 4 8

OUTPUT:
THE DECODED MESSAGE: Truth Always Wins  
20.
Write a program to create a square metre of order N and whose maximum size is 11 you are then required to fill 
the matrix by value ranging from 1 to N2  and then display the matrix on the screen

For Example if N = 5
then matrix would be

 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com