0% found this document useful (0 votes)
4 views

double_dimension_Array_Practical_Programming

Uploaded by

6725
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)
4 views

double_dimension_Array_Practical_Programming

Uploaded by

6725
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/ 4

Question 1

The result of a quiz competition is to be prepared as follows:


The quiz has five questions with four multiple choices (A, B, C, D), with
each question carrying 1 mark for the correct answer. Design a program
to accept the number of participants N such that N must be greater than
3 and less than 11. Create a double-dimensional array of size (Nx5) to
store the answers of each participant row-wise. Calculate the marks for
each participant by matching the correct answer stored in a single-
dimensional array of size 5. Display the scores for each participant and
also the participant(s) having the highest score.
Example: If the value of N = 4, then the array would be:

Q1 Q2 Q3 Q4 Q5

Participant 1 A B B C A

Participant 2 D A D C B

Participant 3 A A B A C

Participant 4 D C C A B

Key to the question: D C C B A

Note: Array entries are line fed (i.e. one entry per line)
Test your program for the following data and some random data.
Example 1
INPUT:
N=5
Participant 1 D A B C C
Participant 2 A A D C B
Participant 3 B A C D B
Participant 4 D A D C B
Participant 5 B C A D D
Key: B C D A A
OUTPUT:
Scores:
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2
Highest Score:
Participant 5
Example 2
INPUT:
N=4
Participant 1 A C C B D
Participant 2 B C A A C
Participant 3 B C B A A
Participant 4 C C D D B
Key: A C D B B
OUTPUT:
Scores:
Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3
Highest Score:
Participant 1
Participant 4
Example 3
INPUT:
N = 12
OUTPUT:
INPUT SIZE OUT OF RANGE.

Question 2

Write a program to declare a matrix A[ ] [ ] of order (MN) where ‘M’ is the number of
rows and ‘N’ is the number of columns such that the values of both ‘M’ and ‘N’ must be
greater than 2 and less than 10. Allow the user to input integers into this matrix.

Perform the following tasks on the matrix:


(a) Display the original matrix.
(b) Sort each row of the matrix in ascending order using any standard sorting
technique.
(c) Display the changed matrix after sorting each row.

Test your program for the following data and some random data:
Example 1:
INPUT: M = 4
N=3
ENTER ELEMENTS OF MATRIX
11 -2 3
5 16 7
904
318

OUTPUT:
ORIGINAL MATRIX
11 -2 3
5 16 7
904
318
MATRIX AFTER SORTING ROWS
-2 3 11
5 7 16
049
138
Example 2:
INPUT: M = 3
N=3
ENTER ELEMENTS OF MATRIX
22 5 19
7 36 12
9 13 6
OUTPUT:
ORIGINAL MATRIX
22 5 19
7 36 12
9 13 6

MATRIX AFTER SORTING ROWS


5 19 22
7 12 36
6 9 13

Example 3:
INPUT: M = 11
N=5
OUTPUT:
MATRIX SIZE OUT OF RANGE

You might also like