How to slove this ??

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
How to slove this ??
Collapse context ←
HW7 - Chapter 8 - 2D Array -Find the sum above or below the main
diagonal in any n by n matrix
Write a code to find either the sum above or below the main diagonal of an n by n matrix MAT of integer values. The main diagonal represents all the elements
denoted by MAT[x][x] where x is the values between 0 and n-1. First, the program asks the user to enter the size of the matrix n. Then the user should enter 0
to either find the sum of the elements in the region above the diagonal or 1 to find the sum of the elements under the diagonal. Finally, the user has to insert
the n*n elements of the matrix in a row order where the elements of the first row will be inserted first and then the second row and so on. The output simply
represents the desired sum value.
IMPORTANT NOTES:
• If the matrix size <0, the output will be "Negative input".
• If the matrix size = 0, the output will be "Zero size matrix".
• If the user input for the desired region is not 0 or 1 then the output will be "Wrong entry".
• The user will not be given the chance to enter the matrix values if any of the previous conditions occured.
1/0
Program Input:
• Array size (n)
• Desired region(0 or 1)
. n*n integer elements
A single line that shows the desired sum value
Program Output:
Transcribed Image Text:Collapse context ← HW7 - Chapter 8 - 2D Array -Find the sum above or below the main diagonal in any n by n matrix Write a code to find either the sum above or below the main diagonal of an n by n matrix MAT of integer values. The main diagonal represents all the elements denoted by MAT[x][x] where x is the values between 0 and n-1. First, the program asks the user to enter the size of the matrix n. Then the user should enter 0 to either find the sum of the elements in the region above the diagonal or 1 to find the sum of the elements under the diagonal. Finally, the user has to insert the n*n elements of the matrix in a row order where the elements of the first row will be inserted first and then the second row and so on. The output simply represents the desired sum value. IMPORTANT NOTES: • If the matrix size <0, the output will be "Negative input". • If the matrix size = 0, the output will be "Zero size matrix". • If the user input for the desired region is not 0 or 1 then the output will be "Wrong entry". • The user will not be given the chance to enter the matrix values if any of the previous conditions occured. 1/0 Program Input: • Array size (n) • Desired region(0 or 1) . n*n integer elements A single line that shows the desired sum value Program Output:
Sample Testcase 0:
Input:
(-2)
Output:
Negative input
Sample Testcase 1:
Input:
0
Output:
Zero size matrix
Sample Testcase 2:
Input
32
Output:
Wrong entry
Transcribed Image Text:Sample Testcase 0: Input: (-2) Output: Negative input Sample Testcase 1: Input: 0 Output: Zero size matrix Sample Testcase 2: Input 32 Output: Wrong entry
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY