Description
Write a C++ program to do the following :
1. Create two 2D Arrays ( Array_1 , Array_2 ). Each array is of size 3 x 3.
2. Write a function to populate both arrays with distinct random numbers
that are between 1 and 12.
3. Write a function to display both arrays.
4. Write a function to add Array_1 to Array_2 and place the result in Array_3.
Display Array_3.
5. Write a function to multiply Array_1 by Array_2 and place the result in
Array_3. Display Array_3.
6. Write a function to display the transposed of Array_1 .
7. Write a function to display the determinant of Array_1.
8. Write a display the sum of elements of each row in Array_1.
9. Write a display the sum of elements of each column in Array_1.
10. Write a display the sum of both diagonal elements in Array_1.
11. Use a function to determine whether Array_1 is a special array.
special Array is an arrangement of distinct numbers (i.e. each number is
used once), usually integers, in a array grid, where the numbers in each row,
and in each column, and the numbers in the main and secondary diagonals,
all add up to the same number.
12. Repeat steps 2 – 11 until the user terminates the program.
At
the
beginning
of
your
program
(
and
before
the
#include
statement
),
include
the
following
:
Header comments (file documentation block) should be at the top of each file and
should contain: Author / s, Due Date, Assignment Number, Course number and
section, Instructor, and a brief description of the purpose of the code in the file. For
example :
//
//
//
//
//
//
//
//
Author
/
s
:
(Your
names
here!!)
Due
Date
:
Programming
Assignment
Number
Variable names :
•
•
•
Must be meaningful.
The initial letter should be lowercase, following words should be capitalized, no other
caps or punctuation ( i.e. weightInPounds
).
Each variable must be declared on a separate line with a descriptive comment.
Named constants :
•
•
•
Use for most numeric literals.
All capitals with underscores ( i.e. TX_STATE_SALES_TAX
Should occur at top of function, or global (only if necessary)
)
Line length of source code should be no longer than 80 characters (no wrapping of
lines).
Indentation :
•
•
•
Use 2-4 spaces (but be consistent throughout your program).
Indent blocks, within blocks, etc.
Use blank lines to separate sections.
Spring
–
CS3358
-‐
Husain
Gholoom
Page
3
Data Structures
Programming Assignment 1
Comments for variables :
All variable definitions should be commented as follows:
int
gender;
// integer value for the gender,
// 1 = Male , 2 = Female ,
Rules
:
1. Your
program
must
compile
and
run
using
latest
version
of
codeblocks
under
windows.
2. Your
program
must
be
documented
according
the
style
above
.
See
the
website
for
the
sample
programming
style
program.
3. Must
use
random
number
generator
to
generate
the
3-‐digit
number
.
4. Must
use
at
least
10
functions
other
than
your
main
function.
5. You
are
not
allowed
to
use
global
Arrays
,
global
variables
…
etc.
You
are
also
not
allowed
to
classes
and
pointers.
6. You
must
use
the
appropriate
libraries
in
writing
this
program.
7. Must
properly
format
the
output
as
it
is
shown
on
the
sample
run
below.
Replace
my
name
with
your
name
8. You
must
name
your
program
as
:
o SP18_3358_S#_LastName_FirstName_PG1.cpp
// S# is section Number
Where
LastName
is
your
Last
Name
and
FirstName
is
your
First
Name,
and
S#
is
your
section
number.
For
example
,
the
file
name
should
look
something
like
:
SP18-‐3358_0_Gholoom_Husain_PG1.cpp
(
not
.cbp
)
or
SP18-‐3358_1_Gholoom_Husain_PG1.cpp
(
not
.cbp
)
or
SP18-‐3358_2_Gholoom_Husain_PG1.cpp
(
not
.cbp
)
9. You
must
upload
your
programs
no
later
than
the
starting
of
class
time
on
the
due
date.
No
late
assignments
will
be
accepted.
Everyone
must
upload
their
program
electronically.
Use
Tracks
To
upload
your
program.
Spring
–
CS3358
-‐
Husain
Gholoom
Page
4
Data Structures
Programming Assignment 1
10. You
must
also
turn
in
hard
copy
of
your
source
code
no
later
than
the
starting
of
class
time
on
the
due
date
.
should
the
hard
copy
consist
of
more
than
one
page
,
then
,
the
hard
copy
must
be
stapled.
if
you
are
unable
to
turn
in
a
printout
during
class,
you
can
take
the
program
to
the
computer
science
department
and
hand
it
to
the
front
desk
personal
(Comal
211
)
before
the
deadline.
Make
sure
that
the
front
office
stamps
the
program.
Make
sure
that
include
the
date
and
time.
Finally
,make
sure
that
they
place
the
program
in
my
mailbox.
One
hard
copy
per
group.
DO
NOT
slide
your
program
under
my
office
door
–
It
will
NOT
be
accepted
The following points will be deducted if :
• Incorrect file format such as uploading .cbp instead of .cpp , missing
electronic copy , missing the hardcopy using .h and .cpp files ,
Compilation Errors , Using global variables, global arrays , vectors
or global vectors … etc
( – 10 points )
• Other ( 0.5 point each ) :
•
•
•
•
•
•
Logical Errors
Unable to read the source code due to unclear printing
Incorrect program file name.
Incorrect output format.
More than one hardcopy per group or Hard copy is not stapled.
Incorrect Style such as but not limited to Missing output header
, output footer , comments or program documentations , missing
roster number , missing section number, … etc