ClassXI Hy2021 Comp - Sc.
ClassXI Hy2021 Comp - Sc.
2. Write the output of the following code snippet if display() method is called with two parameters
whose value is given with the code. Also show detailed dry run. [3]
class Output_xi
{
static void display(int a,int b) // test the code for a=3, b=10
{
int i=3;
for(;i<=b;i+=3)
{
a+=b%i++;
switch(i)
{
case 2: b+=a++ - i++ + a;
case 4:System.out.println(a+b);
case 6: i+=2;
a%=b++/++i;
break;
default:
System.out.println(a+","+b+i);
}
}
System.out.println(a+b+i);
}
}
4. a) From the given truth table write the POS expression of X. [2]
A B C X
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
b) Reduce the boolean expression to its simplest form: A.(B + C(A.B + A.C)’). Write the laws at each step.
[2]
c) State whether the following proposition is tautology, contradiction or a contingency.
F=(P => Q) V (Q => ~P) [1]
OR
5.a) Verify if the following is valid or not using truth table: (a=>b).(a=>c) = a=>(b.c) [2]
b) Design the circuit to derive NOR gate using NAND gates only. [2]
c) Derive the reduced expression of SUM of Full Adder circuit from its truth table. [1]
Each program should be written in such a way that it clearly depicts the logic of the problem.
This can be achieved by using mnemonic names and comments in the program. (Flowcharts and
Algorithms are not required.) The programs must be written in Java.
6. Write a program which will accept a 2d array and a number to search. It will print the Sum of the
index(row index + column index) if the number is found both in row and its corresponding column.
[10]
The details of the class are as follows :
Class Name : NumberArray
Instance variable mat[][] : Integer array of size mxn
A number (no ) to search
void accept() : Accept the value of m and n , create the array and accept positive elements in it. It will
also accept the number to search(no)
void display() : Show the 2 d array
int checkRow(int r ) : return the index of the search no in rth row otherwise return -1
int checkCol(int c) : return the index of the search no in cth column otherwise return -1
void showIndex() : Print the sum of index of no in row and column if present otherwise
give a relevant error message
No need to write the main()
Eg
Matrix mat 4578
3674
1615
no= 7
The sum of the index = 2(7 is found in 3rd column ) +1 ( 2nd row of the corresponding column) which
is 3.
OR
7. A palindrome number is one that reads same from left to right or right to left. [10]
There is an ingenious method to get the palindrome from any positive integer.
Data member:
Member functions:
int ingenious( int) :a function that calculates and return the palindrome number
Specify the class, giving details of the functions members along with main method that accept a number
and print its palindrome number by calling above methods. [10]
In the program some codes are missing and they are termed as ?1? , ?2?,?3?,?4?,?5?
*****************************************************************************