Stdio.h format.
Proper commenting please.
Needs to be able to be saved as a .C file.
Thanks in advance.
Please do not copy and paste any of the other answers already on
this site as they do not work. If you can't do it please don't
answer my question.
#include <stdio.h>
void transposeMatrix(int M[4][5], int N[5][4])
{
// variable i will access each row index 1 by 1
for (int i = 0; i < 4; ++i)
{
// var j will access all column index for each row i
for (int j = 0; j < 5; ++j)
{
// place 1st row of M into 1st column of N
N[j][i] = M[i][j];
}
}
}
int main(int argc, char const *argv[])
{
// define array M(4x5) abd initilized it
int M[4][5]={
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20}
};
// define array N[5x4] and initilizedit with 0
int N[5][4] = {0};
// call transposeMatrix function
transposeMatrix(M, N);
// print original matrix M
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 5; ++j)
{
printf("%4d ",M[i][j]);
}
printf("\n");
}
printf("\n\n");
//print transpose matrix N
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < 4; ++j)
{
printf("%4d ",N[i][j]);
}
printf("\n");
}
return 0;
}
Stdio.h format. Proper commenting please. Needs to be able to be saved as a .C file....
help with all but priority on last 2 questions 2. Cut and file with yower namme on the Sirst pae to Biacsbownd (holkdert Course . Upload the word file with ower o1. (25 pts) Matrix A (6x6) is defined as 35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 22 27 20 8 28 33 17 10 15 0 534 12 14 16 4)36 29 13 18 11 Write a script to find the...
Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8 9 10 11; 23 9 16 15 ;11 12 3 6; 1 2 8 9 ) ? = ( 2 21 7 15; 12 4 8 22; 23 9 5 13; 23 4 21 22) ℎ = (4 9 12 15) b. Add suitable lines of codes to the M-file to do the following. Each of the following points should be coded in only...
Diagonal Difference HackerRank Pseudocode and C++: Given a square matrix, calculate the absolute difference between the sums of its diagonals. Function Description Complete the diagonalDifference function described below to calculate the absolute difference between diagonal sums. diagonalDifference( integer: a_size_rows, integer: a_size_cols, integer array: arr) Parameters: a_size_rows: number of rows in array a_size_cols: number of columns in array a: array of integers to process Returns: integer value that was calculated Constraints -100 < = elements of the matrix < = 100...
C Programming #include <stdio.h> #include <stdlib.h> #include <time.h> // These defines do a text replacement // everytime the string 'ROWS' and 'COLUMNS' // are found in this specific source file. // You can play with these values. #define ROWS 5 #define COLUMNS 5 /* ============= Tutorial on Graph format ============ You are given a randomly generated graph that looks of the form: 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0...
C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <iostream> #include <fstream> #include <string> using namespace std; int measureElementsPerLine(ifstream& inFile) { // Add your code here. string line; getline(inFile, line); int sp = 0; for (int i = 0; i < line.size(); i++) { if (line[i] == ' ') sp++; } sp++; return sp; } int measureLines(ifstream& inFile) { // Add your code here. string line; int n = 0; while (!inFile.eof()) { getline(inFile,...
Please code in C++. link to continue the code is this below or you can make your own code if you wish(fix any mistakes if you think there are any in it): cpp.sh/3qcekv 3. Submit a header file (project3.h), a definition file (project3.cpp), a main file (main.cpp), and a makefile to compile them together. Make sure to run the command make and produce an application file and include it with your submission. For this project, you are required to create...
Problem 1 Write your code in the file MatrixOps.java. . Consider the following definitions from matrix algebra: A vector is a one-dimensional set of numbers, such as [42 9 20]. The dot product of two equal-length vectors A and B is computed by multiplying the first entry of A by the first entry of B, the second entry of A by the second entry of B, etc., and then summing these products. For example, the dot product of [42 9...
Could you do that in C language? Here is the code which we got #include <stdio.h> #define MAX_SIZE 20 // function definitions void displaySpiral(int matrix[][MAX_SIZE], int size); void displayMatrix(int matrix[][MAX_SIZE], int size); int takeInput(int inputMatrix[][MAX_SIZE]); int main() { int matrix[MAX_SIZE][MAX_SIZE]; int matrixSize = takeInput(matrix); printf("Displaying the whole matrix:\n"); fflush(stdout); displayMatrix(matrix, matrixSize); printf("Now, displaying the matrix in a spiral way:\n"); fflush(stdout); displaySpiral(matrix, matrixSize); return 0; } // already implemented for you int takeInput(int inputMatrix[][MAX_SIZE]) { int size; printf("What is the size...
Please explain answer :D Question 5 (5 marks] Consider the syntactically correct C code below, which is missing a function print_diagonal include <stdio.h> • typedef int Table(100) (100); */• print diagonal (T, n) . Given a Table T, which will have n rows and n columns, print all of the 1 entries on the main diagonal of T (that is, entries whose row number and column number are equal). Remember to print a newline at the end. / ► /...
Use the create_matrix function from the tutorial file, along with a function a (i, j) (which you will have to create) to produce the following 17 × 17 matrix. Then find its determinant. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 1 1 1 1 1 1 1 1 1 1 1...