End (2021)
End (2021)
1 Lets find what is the final outcome of the board game by seeing the final 10
board. The board is a 3×3 matrix. Each board position can have either 0 or 2
as elements. If T0 represents total number of 0’s in matrix, T2 represents total
number of 2’s in matrix, then it must satisfy condition T0=T2+1 or T0=T2-
1.If condition between T0 and T2 fails, “invalid player movement” message is
displayed. Now if all 3 elements of any row or column are same (0 or 2) or all
3 elements of diagonal position are same (0 or 2) then display “(0 or 2)-You
win the Match”. If above condition fails, then display “Match Draw”.
Write C program to take all 9 inputs of 3×3 matrix and display matrix. Then
check above conditions to find final outcome of the match (0 or 2 wins match,
match draw) and display message accordingly
0 2 2 0 0 2 0 2 2
0 0 2 2 2 0 2 0 2
2 Lets design and play a game with marbles. We have one 4*4 main 10
board(MB) and one 1*1 side board (SB) as shown below .Initially 28
marbles are there in SB. We can pick any number of marbles from side
board(SB) and place it in any position / place in MB except the 4 positions
marked as X in MB. However we need to place the marbles in such a way
that following condition always satisfied - total no. of marbles in
row1,row4,col1,col4 are 8.We will repeat this process as shown in the
diagram .After the first step ,6 marbles are left in SB .In the 2nd step ,we
pick one marble from SB (so 5 marbles are left)and place it in row1 of
MB and then rearrange marbles in other place to satisfy the condition-
total no. of marbles in row1,row4,col1,col4 are 8. Step3 and step4 are also
shown to understand the game. You need to show the remaining steps (till
0 marbles left in SB) displaying no. of marbles in row & col you place in
a way so that condition - total no. of marbles in row1,row4,col1,col4 are 8
is satisfied. Highlight with square marks (as shown in step2-4) the
position in MB where you add new marble and rearranged marbles to
satisfy condition.
Also write c program to display the final output of each step (no need to
display internal stepwise rearrangement output) of this game. Display 0 in
place of X of MB.
3 Write a program to take last two decimal digits of your roll no as input and 5
find least significant byte (LSB) of it. Now check if first 4bits of LSB are
equal to last 4 bits of LSB or not. For example if LSB is 1000 1000 then
output will be "Equal" and if LSB is 1000 1010 then output will be "Not
equal".
4 Write a program to calculate the sum of the factorial of each individual digit 5
of a number
5 Write a program to print the below given series using recursion 5
1,2,5,12,29,70,169
6. Write a program that takes two integer type numbers as input and display 5
results of following operations between them - BITWISE AND (&),
BITWISE OR (|) based on choice '&' or '|' entered by user. Use function int
Bitwise(int,int,char) to compute and store result of operation. Also use
switch-case in the program. Display output of your program by taking your
roll no and next roll no as two inputs and choice '&' or '|'.
7. Write a program that replaces a word ‘hello’ with another word ‘bye’ in a file 5
"test.txt", and return total number of replacements.
8. Write a program that will take information of all the students from a user. 5
Each individual student's information will be stored in a record, where a
student record will have three fields, which are student name, age and height.
The number of records will be equal to the number of students in a class. In
addition, the program also has to print the record of each student using the
pointer.