‹ Back to the paper
A class Composite contains a two dimensional array of order [m x n]. The maximum value possible for…
A class Composite contains a two dimensional array of order [m x n]. The maximum value possible for both ‘m’ and ‘n’ is 20. Design a class Composite to fill the array with the first (m x n) composite numbers in column wise. The details of the members of the class are given below:
Class name : Composite
Data members/instance variables:
arr[ ] [ ] : stores the composite numbers column wise
m : integer to store the number of rows
n : integer to store the number of columns
Member functions/methods:
Composite(int mm, int nn) : to initialize the size of the matrix m=mm and n=nn
int isComposite(int p) : returns 1 if number is composite otherwise returns 0
void fill() : to fill the elements of the array with the first (m × n) composite numbers in column wise
void display() : displays the array in a matrix form
Specify the class Composite giving details of the constructor(int,int), int isComposite(int), void fill() and void display(). Define a main() function to create an object and call the functions accordingly to enable the task.
Answer
No answer yet.
From ISC 2020 Specimen Computer Science Paper 1, question 7.