please can you do that in c++ , and please comet in the rulse and important notes and (do not) use sscanf scanf           Sample Testcase 0: Input: (-2) Output: Negative input Sample Testcase 1: Input: 0 Output: Zero size matrix Sample Testcase 2: Input 3 2 Output: Wrong entry Sample Testcase 3: Input 3 0 1 2 3 4 5 6 7 8 9 Output: 11 Sample Testcase 4: Input 3 1 1 2 3 4 5 6 7 8 9 Output: 19

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
please can you do that in c++ , and please comet in the rulse and important notes and (do not) use sscanf scanf  
 
 
 
 
Sample Testcase 0:
Input:

(-2)

Output:

Negative input

Sample Testcase 1:
Input:

0

Output:

Zero size matrix

Sample Testcase 2:

Input

3 2

Output:

Wrong entry

Sample Testcase 3:

Input

3 0 1 2 3 4 5 6 7 8 9

Output:

11

Sample Testcase 4:

Input

3 1 1 2 3 4 5 6 7 8 9

Output:

19

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.
I/O
Program Input:
• Array size (n)
• Desired region(0 or 1)
●
n*n integer elements
Program Output:
• A single line that shows the desired sum value
Transcribed Image Text: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. I/O Program Input: • Array size (n) • Desired region(0 or 1) ● n*n integer elements Program Output: • A single line that shows the desired sum value
1 #include <iostream>
2 #include <cmath>
3 using namespace std;
4
5
int main()
6
{
7
8
int s, region;
9
cin>>s>>region;
10
11
int MAT [s] [s];
12
13
//Start your code Here
14
15
16
17
return 0;
18 }
19
Transcribed Image Text:1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 5 int main() 6 { 7 8 int s, region; 9 cin>>s>>region; 10 11 int MAT [s] [s]; 12 13 //Start your code Here 14 15 16 17 return 0; 18 } 19
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

please can you do that in c++ , and please stick in the rulse and important notes and (do not) use sscanf or scanf  

 

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.
I/O
Program Input:
• Array size (n)
• Desired region(0 or 1)
●
n*n integer elements
Program Output:
• A single line that shows the desired sum value
Transcribed Image Text: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. I/O Program Input: • Array size (n) • Desired region(0 or 1) ● n*n integer elements Program Output: • A single line that shows the desired sum value
1 #include <iostream>
2 #include <cmath>
3 using namespace std;
4
5
int main()
6
{
7
8
int s, region;
9
cin>>s>>region;
10
11
int MAT [s] [s];
12
13
//Start your code Here
14
15
16
17
return 0;
18 }
19
Transcribed Image Text:1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 5 int main() 6 { 7 8 int s, region; 9 cin>>s>>region; 10 11 int MAT [s] [s]; 12 13 //Start your code Here 14 15 16 17 return 0; 18 } 19
Solution
Bartleby Expert
SEE SOLUTION
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