Category Archives for C Programming
Programs in C Language
Shell Sort
Sorting using shell sort method. #include <stdio.h> #define MAX 20 main() { int arr[MAX], i,j,k,n,incr; printf(“Enter the number of elements : “); scanf(“%d”,&n); for(i=0;i<n;i++) { printf(“Enter element %d : “,i+1); scanf(“%d”,&arr[i]); } printf(“Unsorted list is :\n”); for (i = 0; … Continue reading
Matrix Inverse Code as Module using Pointers
This module is created by Helton S. Gaspar from one of my posts Inverse of a Matrix. He emailed me the code. I think it will be useful for you people. Continue reading
Decimal to Binary without using Array
Program to convert binary to decimal without using array. #include<stdio.h> int main() { int dec,i=1,rem,res=0; printf("Enter the Value "); scanf("%d",&dec); while(dec!=0) { res=res+(i * (rem=dec%2)); dec=dec/2; i=i*10; } printf("\nThe Binary value is %d\n",res); }
path matrix by Warshall’s algorithm
Program to find path matrix by Warshall's algorithm. #include<stdio.h> #include<conio.h> #define MAX 20 int main() { int i,j,k,n; int w_adj[MAX][MAX],adj[MAX][MAX],path[MAX][MAX]; printf("Enter number of vertices : "); scanf("%d",&n); printf("Enter weighted adjacency matrix :\n"); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&w_adj[i][j]); printf("The weighted adjacency matrix … Continue reading
program for topological sorting
Program for topological sorting. #include<stdio.h> #define MAX 20 int n, adj[ MAX ][ MAX ]; int front = -1, rear = -1, queue[ MAX ]; main() { int i, j = 0, k; int … Continue reading
traversing a graph through BFS and DFS
Program for traversing a graph through BFS and DFS. #include<stdio.h> #define MAX 20 typedef enum boolean{false, true} bool; int adj[ MAX ][ MAX ]; bool visited[ MAX ]; int n; /* Denotes number of nodes in the … Continue reading
minimum spanning tree from Prim’s algorithmP
Program for creating minimum spanning tree from Prim's algorithm. #include<stdio.h> #define MAX 10 #define TEMP 0 #define PERM 1 #define FALSE 0 #define TRUE 1 #define infinity 9999 struct node { int … Continue reading
path matrix by powers of adjacency matrix
Program to find out the path matrix by powers of adjacency matrix. #include<stdio.h> #define MAX 20 int n; main() { int w_adj[ MAX ][ MAX ], adj[ MAX ][ MAX ], adjp[ MAX ][ MAX ]; … Continue reading

