answersLogoWhite

0

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.

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
BeauBeau
You're doing better than you think!
Chat with Beau
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
More answers

I've written the function for a 3x3 matrix. In 3x3 upper triangular matrix, there are 3 elements whose value is 0 (i < j).. So, when count is 3, program will display that matrix is upper triangular. You can modify the function as per your matrix size.

void upper() // Function for finding Upper Triangular Matrix
{
int count = 0;
printf("\nEnter a matrix ");
for(i = 0; i <= 2; i++)
for(j = 0; j <= 2; j++)
scanf("%d", &a[i][j]);

for(i = 0; i <= 2; i++)
{
for(j = 0; j <= 2; j++)
{
if(i <= j)
{
if(a[i][j] == 0)
count++;
}
}
}
if(count == 3)
printf("\nThe Matrix is upper triangular\n");
else
printf("\nThe Matrix is not upper triangular\n");
}

int main() // Main Function
{
upper();
)

User Avatar

Wiki User

15y ago
User Avatar

displaying the apper & lower triangle matrixe in c++

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: C program for upper triangular matrix for a given matrix?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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; }


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 programm to check whether a matrix is upper triangular or lower trianglular?

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


Is uppercase used in a C program?

By convention, all upper-case is used to identify macros and single capitals to identify template parameters. However, programmers are free to use upper-case as they see fit.


Write a program using c plus plus to whether the given square matrix is symmetric or not?

int sym_test (const int **a, int n) {int i, j, sym;i=1, j=0, sym=1;while (sym && i