#include<stdio.h> #include<conio.h> #define max 20 int adj[max][max]; //Adjacency matrix int n; //Denotes number of nodes in the graph void main() {
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label matrix. Show all posts
Showing posts with label matrix. Show all posts
C Program To Represent Directed or Undirected Graph Using Adjacency Matrix
C program to represent directed or undirected graph using Adjacency matrix.
Labels:
$ccpp
,
adjacency
,
c program
,
code
,
create
,
data structure
,
directed
,
graph
,
graphs
,
How to
,
matrices
,
matrix
,
programming
,
represent
,
representation
,
undirected
,
using
C Program to Sort a Matrix Column wise using Pointers
This is a c program to sort a mxn matrix column wise in ascending order using pointers. To sort column wise in descending order, just replace the '>' symbol in the comparing line of code into '<'. That part of the code is marked with a comment 'comparison'.
#include<stdio.h> main() { int a[7][7],i,j,k,m,n,temp; //reading printf("enter number of rows of matrix\n"); scanf("%i",&m); printf("enter number of columns of matrix\n"); scanf("%i",&n); printf("enter the elements\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&a[i][j]); } //displaying printf("the matrix you entered:\n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<n;j++) { printf("%4d",*(*(a+i)+j)); } }
Labels:
$ccpp
,
c language
,
c program
,
column wise
,
matrix
,
pointers
,
programme
,
programming
,
sort
,
sorting
,
source code
,
to
,
using
C Program to Calculate Determinant of Matrix of Order Upto 3
In this post i am sharing a C program to calculate determinant of matrices of order upto 3 (3x3).
#include<stdio.h> void main() {int a[10][10],i,m,j; int det=0; printf("\nEnter the order of matrix:\n "); scanf("%i",&m); printf("\nenter elements\n"); for(i=0;i<m;i++) { for(j=0;j<m;j++) scanf("%d",&a[i][j]); } printf("\nThe matrix is\n"); for(i=0;i<m;i++) { printf("\n"); for(j=0;j<m;j++) printf("%3d",a[i][j]); } printf("\nthe transpose is\n"); for(i=0;i<m;i++) { for(j=0;j<m;j++) printf("%3i",a[j][i]); printf("\n"); } if(m==1) { det=a[0][0]; printf("det=%i",det); }
Subscribe to:
Posts
(
Atom
)