To write a C Program To Print Tridiagonal Matrix in C Programming Language -
Solution For C Program :
/*C Program To Print Tridiagonal Matrix.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
int mat[5][5]={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}};
printf("Entered matrix is:\n\n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%d\t",mat[i][j]);
}
printf("\n");
}
printf("\nTridiagnal matrix:\n\n");
printf("%d\t%d\n",mat[0][0],mat[0][1]);
for(i=1;i<5;i++)
{
for(k=1;k<i;k++)
{
printf("\t");
}
if(i==4)
printf("%d\t%d\n",mat[4][3],mat[4][4]);
else
{
for(j=i;j<5;j++)
{
if(i==j)
printf("%d\t%d\t%d",mat[i][j-1],mat[i][j],mat[i][j+1]);
}
printf("\n");
}
}
getch();
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
Matrix
- C Program To Find Transpose Of A Matrix
- C Program To Multiply Two Matrices
- C Program To Understand Use Of Pointers In MATRIX
- C Program : 4x4 Matrix Keypad connected to Arduino. This code prints the key pressed on the keypad to the serial port.
- C Code/Program For Swap Matrix
- matrix sort in C Program
- Sequential Matrix Multiplication C Program
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C program to display the transpose of given 3 X 3 matrix
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- C Program Shortest Distance in Matrix
- C Program To Read The Adjecancy Matrix of Directed Graph And Convert It Into Adjecancy List
print
- PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C
- Write a c program to print Pascal triangle.
- C or C++ Program To Print Prime Number
- C Program print fill zero & mod/div
- C Program to printf & scanf Example
- C Program to Print a String Without Use Semicolon.
- C Program To Input & Print More Than One Words In Single Line
- C Program To Print Alphabets Like {Aa Bb Cc...}
- C Program To Print Alphabets Like {Az By Cx...}
- C Program To Print Lines Of A Paragraph Having More Than 15 Characters
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print String In Formatted Output Form
- C Program To Print Sum Of n Digit Number
- C Program To Print Table Horizontally
- C Program To Print Text Into Uppercase
- Printing ASCII Table with Numbers and corresponding characters
- C Program to print all prime numbers from 1 to 300.
- C program that lets the user choose if he wants to add a item to the shopping list or print it out
- C Program to print table vertically
- Loudness Program: Gets loudness level from user; chooses a response And prints it using logical and operative statements
- C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result
- Function should print the cartesian coordinates of the struct argument
- C Program Read a char & print next char ( file to file )
- Primul meu program in C Program
Tridiagonal