Question

Read your notes concerning 2D arrays with particular attention to the syntax of passing arrays as...

  1. Read your notes concerning 2D arrays with particular attention to the syntax of passing arrays as parameters to functions.
  2. Write the pseudocode (algorithm) for the following program definition: A text file contains a square matrix of integer numbers. The file contains an integer number indicating the identical number of rows and columns followed by the data itself (that number cannot be larger than 100). For example, a file containing a 3x3 matrix would contain 3 followed by 9 other integer numbers. The program will call one function to determine if all the numbers on the main diagonal are the same.
  3. The function is called checkdiag (int checkdiag (int matrix[][100], int size)) that will return 1 if all the numbers on the main diagonal are the same and 0 otherwise.
  4. Your program will read the array from the file, check the diagonal and print a report containing the size and the status of the diagonal. A typical report would look like The matrix is 3x3 and all the numbers on the main diagonal are the same. Check your algorithm with the following data files: matrix1.txt, matrix2.txt, matrix3.txt, matrix4.txt.\
  1. Using Geany, write the C program based on your algorithm.
  2. Eliminate the syntax errors.
  3. Debug your program if necessary until you get correct results.
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Read your notes concerning 2D arrays with particular attention to the syntax of passing arrays as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C programming...

    Write a text file contains a square matrix of integer numbers. The file contains an integer number indicating the identical number of rows and columns followed by the data itself (that number cannot be larger than 100). For example, a file containing a 3x3 matrix would contain 3 followed by 9 other integer numbers. The program will call one function to determine if all the numbers on the main diagonal are the same.The function is called checkdiag (int checkdiag (int matrix[][100], int...

  • Using C programming

    Write another function called checkdiag2 (int checkdiag2 (int matrix[][100], int size)) that will return 1 if all the numbers on the antidiagonal are the same and 0 otherwise.Rewrite your main program to use 2D dynamic allocation instead for your array. Your array will have rows and columns depending of the first integer read from the file.Call your function from the main program. A typical report would look like The matrix is 8x8 and all the numbers on the antidiagonal are the same.Check your...

  • Arrays Arravs Introduction Your ninth programming assignment will consist of two C++programs. Your programs should compile...

    Arrays Arravs Introduction Your ninth programming assignment will consist of two C++programs. Your programs should compile correctly and produce the specified output. Please note that your programs should comply with the commenting and formatting rules we discussed in class. Please see the descriptive ile on eLearning for details. Program 1- Linear Search Algorithm In Computer Science, it is often very important to be able to locate a specific data item inside a list or collection of data. Algorithms that perform...

  • Update your first program to dynamically allocate the item ID and GPA arrays. The number of...

    Update your first program to dynamically allocate the item ID and GPA arrays. The number of items will be the first number in the updated “student2.txt” data file. A sample file is shown below: 3 1827356 3.75 9271837 2.93 3829174 3.14 Your program should read the first number in the file, then dynamically allocate the arrays, then read the data from the file and process it as before. You’ll need to define the array pointers in main and pass them...

  • Matrix Multiplication with Threads - C/C++ **Please read entire question before answering** In this assignment you...

    Matrix Multiplication with Threads - C/C++ **Please read entire question before answering** In this assignment you will use the Pthreads library to write a program that multiplies two square arrays and compare the difference between the imperative and parallel implementations of this algorithm. Use the matrix mulltiplication algorithm. Write a program that contains three functions: (1) A function that has an integer as a parameter and returns a pointer to square array of integers (i.e. both dimensions should be equal)....

  • Mountain Paths (Part 1) Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e...

    Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...

  • Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures...

    Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...

  • Given a 2d matrix of size N x M (which must be read from a file...

    Given a 2d matrix of size N x M (which must be read from a file provided to you), transpose it into a M x N matrix where N is the number of rows and M is the number of columns. void transpose(int n, int m, const int A[n][m], int AT[m][n]); Write a main() program to test and demonstrate your function. Show your function works for, at minimum, 3x6 and 10x6 matrices.

  • Write another function called checkdiag2 (int checkdiag2 (int matrix[][100], int size)) that will return 1 if...

    Write another function called checkdiag2 (int checkdiag2 (int matrix[][100], int size)) that will return 1 if all the numbers on the antidiagonal are the same and 0 otherwise. Rewrite your main program to use 2D dynamic allocation instead for your array. Your array will have rows and columns depending of the first integer read from the file. Call your function from the main program. A typical report would look like The matrix is 8x8 and all the numbers on the...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT