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( )
            








     
                     

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