Skip to content

Instantly share code, notes, and snippets.

@comicalequation
comicalequation / sparsematrixaddition.c
Created February 9, 2017 15:41
A C program code for adding two sparse square matrices using the intermediary (row,column,element) matrix form.
#include<stdio.h>
int main()
{
int i,j,n,c1=1,c2=1,count=1,a[10][10],b[10][10],s[20][20],t[20][20],sum[50][50],last[10][10];
printf("\nEnter dimension:");
scanf("%d",&n);
printf("\nEnter elements of 1st matrix:");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
@comicalequation
comicalequation / sparsematrixtranspose.c
Created February 9, 2017 15:44
A C program code to find transpose of a sparse square matrix using (row,column,element) intermediate form
#include<stdio.h>
int main()
{
int i,j,n,c=1,temp,a[10][10],b[10][10],t[20][20];
printf("\nEnter dimension:");
scanf("%d",&n);
printf("\nEnter elements:");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
@comicalequation
comicalequation / parenthesismatch.c
Last active January 28, 2020 05:10
Parenthesis matching (using stack) program in C
#include<stdio.h>
#define max 50
int k=0;
struct stack
{
char stk[max];
int top;
};
struct stack s;
void push(char);
@comicalequation
comicalequation / postfixeval.c
Created February 27, 2017 13:12
Postfix evaluation using stack in C
#include<stdio.h>
#include<math.h>
#define max 50
struct stack
{
char stk[max];
int top;
};
struct stack s;
void push(char);
@comicalequation
comicalequation / halstead.c
Last active August 31, 2017 15:33
A C program for project planning using Halstead's method
#include<stdio.h>
#include<string.h>
#include<math.h>
double newtraph(float);
double f1(double,double);
double f2(double);
int main()
{
FILE *fileptr;
char filechar[40],ch;
@comicalequation
comicalequation / criticalpathmethod.c
Created September 13, 2017 15:35
A C program for calculating forward pass, backward pass, total float and determining the critical path
#include<stdio.h>
int main()
{
int i,j,d,n,e,c=0,a[15][15],fp[10],bp[10],tf[15][15];
printf("\nEnter no of nodes: ");
scanf("%d",&n);
printf("\nEnter no of edges: ");
scanf("%d",&e);
printf("\nEnter duration in this format: start node, end node, duration\n");
for(i=1;i<=n;i++)
@comicalequation
comicalequation / ctmwr.c
Created September 28, 2017 13:03
A C program implementation of selecting a PPSWR sample using Cumulative Total Method
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,x[100],c[100],X=0,N,n,r;
printf("\nEnter the number of units in population: ");
scanf("%d",&N);
printf("\nEnter the number of units to be selected in the sample: ");
scanf("%d",&n);
printf("\nEnter the sizes of units: ");
@comicalequation
comicalequation / ctmwor.c
Created September 28, 2017 13:04
A C program implementation of selecting a PPSWOR sample using Cumulative Total Method
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,x[100],c[100],a[100],X=0,N,n,r;
printf("\nEnter the number of units in population: ");
scanf("%d",&N);
printf("\nEnter the number of units to be selected in the sample: ");
scanf("%d",&n);
printf("\nEnter the sizes of units: ");
@comicalequation
comicalequation / lahiriwr.c
Created September 28, 2017 13:05
A C program implementation of selecting a PPSWR sample using Lahiri Method
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,x[100],m,N,n,u,v;
printf("\nEnter the number of units in population: ");
scanf("%d",&N);
printf("\nEnter the number of units to be selected in the sample: ");
scanf("%d",&n);
printf("\nEnter the sizes of units: ");
@comicalequation
comicalequation / lahiriwor.c
Created September 28, 2017 13:06
A C program implementation of selecting a PPSWOR sample using Lahiri Method
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,x[100],a[100],m,N,n,u,v;
printf("\nEnter the number of units in population: ");
scanf("%d",&N);
printf("\nEnter the number of units to be selected in the sample: ");
scanf("%d",&n);
printf("\nEnter the sizes of units: ");