answersLogoWhite

0

#include<iostream.h> #include<conio.h> # define n 10 void main( ) { int mat[n][n]; int d; // Input elements cout<< "\n Enter dimension of square matrix:"; cin >> d; for(int i = 0; i < d ; i++) for( int j = 0; j < d ; j++) {cout<<"\n Enter elements for "<< i+1 << "," << +1<"location :"; cin >> mat[i][j]; } clrscr(); //Print the array cout<<"\n The Original matrix : \n\n"; for( i = 0; i < d ; i++) {for( j = 0; j < d ; j++) cout<< mat[i][j]<<"\t"; cout<< "\n"; } //upper half of left diagonal..... cout<<"\n The Upper half of the matrix : \n\n"; for( i = 0; i < d ; i++) { for( j = 0; j < d ; j++) { if(i < j) cout << mat [i][j] << " " ; else cout << " " << " "; } cout << "\n "; } //lower half of left diagonal..... cout<<"\n The Lower half of the matrix : \n\n"; for( i = 0; i < d ; i++) { for( j = 0; j < d ; j++) { if(i > j) cout << mat [i][j] << " " ; else cout << " " << " "; } cout << "\n "; } getch ( ); }

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

C program for upper triangular matrix for a given matrix?

This sounds very much like a homework problem. If you work on it and get started, you found a great place to ask a specific question. However, this is not a place to have your homework done for you.


Program for upper triangular matrix in arrays?

#include&lt;stdio.h&gt; int main(){ int a[3][3],i,j; float determinant=0; printf("Enter the 9 elements of matrix: "); for(i=0;i&lt;3;i++) for(j=0;j&lt;3;j++) scanf("%d",&amp;a[i][j]); printf("\nThe matrix is\n"); for(i=0;i&lt;3;i++){ printf("\n"); for(j=0;j&lt;3;j++) printf("%d\t",a[i][j]); } printf("\nSetting zero in upper triangular matrix\n"); for(i=0;i&lt;3;i++){ printf("\n"); for(j=0;j&lt;3;j++) if(i&gt;=j) printf("%d\t",a[i][j]); else printf("%d\t",0); } return 0; }


Write a c program to determine whether a matrix is singular or not?

A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. &lt;&lt;&gt;&gt; The determinant of a singular matix is zero.


C program for solving gauss seidal method?

#include&lt;stdio.h&gt; int main() { double matrix[10][10],a,b, temp[10]; int i, j, k, n; printf("Enter the no of variables: "); scanf("%d", &amp;n); printf("Enter the agumented matrix:\n"); for(i = 0; i &lt; n ; i++){ for(j = 0; j &lt; (n+1); j++){ scanf("%lf", &amp;matrix[i][j]); } } for(i = 0; i &lt; n; i++){ for(j = 0; j &lt; n; j++){ if(j&gt;i){ a = matrix[j][i]; b = matrix[i][i]; for(k = 0; k &lt; n+1; k++){ matrix[j][k] = matrix[j][k] - (a/b) * matrix[i][k]; } } } } printf("The Upper triangular matrix is: \n"); for( i = 0; i &lt; n; i++){ for(j = 0; j &lt; n+1; j++){ printf("%.2f", matrix[i][j]); printf("\t"); } printf("\n"); } printf("\nThe required result is: "); for(i = n-1; i&gt;=0; i--){ b = matrix[i][n]; for(j = n-1 ; j &gt; i; j--){ b -= temp[n-j]*matrix[i][j]; } temp[n-i] = b/matrix[i][i]; printf("\n%c =&gt; %.2f",97+i, temp[n-i]); } }


Write a program in c to check whether given matrix is prime matrix?

A prime matrix is defined as a matrix where all its elements are prime numbers. To check if a given matrix is a prime matrix in C, you can iterate through each element of the matrix, check if each number is prime using a helper function, and return false if any number is not prime. Here's a simple implementation: #include &lt;stdio.h&gt; int isPrime(int num) { if (num &lt;= 1) return 0; for (int i = 2; i * i &lt;= num; i++) { if (num % i == 0) return 0; } return 1; } int isPrimeMatrix(int matrix[3][3], int rows, int cols) { for (int i = 0; i &lt; rows; i++) for (int j = 0; j &lt; cols; j++) if (!isPrime(matrix[i][j])) return 0; return 1; } int main() { int matrix[3][3] = {{2, 3, 5}, {7, 11, 13}, {17, 19, 23}}; printf(isPrimeMatrix(matrix, 3, 3) ? &quot;Prime Matrix\n&quot; : &quot;Not a Prime Matrix\n&quot;); return 0; }

Related Questions

What is the definition of Uper-triangular matrix?

Uper-triangular Matrix A square matrix A whose elements aij=0 for i>j is called upper triangular matrix.


Can a nonsquare matrix be a triangular matrix?

No. Only square matrices can be triangular.


What is strictly lower triangular matrix?

A strictly lower triangular matrix is a kind of (lower) triangular matrix. Term "lower" implies matrix has elements only in the lower half. The condition "strictly" implies that even the "diagonal" of such lower triangular matrix is populated with '0's. The strictly lower triangular matrix thus has '0's in its diagonal as well as the upper triangle part. In other words, a strictly lower triangular matrix is a lower triangular matrix minus its diagonal.


Definition of Lower-triangular matrix?

Lower-triangular Matrix A square matrix A whose elements aij=0 for i


What is the definition of a diagonal matrix?

Diagonal Matrix A square matrix A which is both uper-triangular and lower triangular is called a diagonal matrix. Diagonal matrix is denoted by D.


Wap to build a sparse matrix as an arraywrite functions to check if the sparse matrix is a square diagonal or lower triangular or upper triagular or tridiagonal matrix?

write a programe to build a sparse matrix as an array. write function to check if the sparse matrix is a square, diagonal,lower triangular, upper triangular or tridiagonal matrix


What does it mean for a matrix to be triangular?

A square matrix in which all the entries of the main diagonal are zero


C program for upper triangular matrix for a given matrix?

This sounds very much like a homework problem. If you work on it and get started, you found a great place to ask a specific question. However, this is not a place to have your homework done for you.


Determinant of a 4x4 matrix?

The determinant of a 4x4 matrix can be calculated using various methods, including cofactor expansion or row reduction. The cofactor expansion involves selecting a row or column, multiplying each element by its corresponding cofactor, and summing the results. Alternatively, row reduction can simplify the matrix to an upper triangular form, where the determinant is the product of the diagonal elements, adjusted for any row swaps. The determinant provides important information about the matrix, such as whether it is invertible (non-zero determinant) or singular (zero determinant).


How to find the Inverse of a square symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the inverse of a square matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the inverse of a symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.