C-programming
Levenshtein Algorithm
Levenshtein distance (LD) is a measure of the similarity between two strings, which we will refer to as the source string (s) and the target string (t). The distance is the number of deletions, insertions, or substitutions required to transform s into t. For example,
=> If s is "test" ..
C++ program to find prime number
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,c=0;
clrscr();
printf("enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
{
..
C coding to find largest word
#include<stdio.h>
#include<conio.h>
void main()
{
int w=0,i=0,j=0,l,a[10],big;
char ch[25],st[10][20];
clrscr();
printf("Enter the string:");
gets(ch);
while(ch[i]!='\0')
{
if(ch[i]==' ')
{
st[w][j]='\0';
a[w]=j;
j=0;
w++;
}
else
{
st[w][j]=ch[i];
i++;
}
i++;
}
big=l=0;
for(i=0;i<w;i++)
{
if(big<a[i])
{
big=a[i];
l=i;
}
}
printf("The longest word is %s",st[1]);
getch();
}
..
C Program to Multiply Matrix Numbers
C Program for Matrix Multiplication Using Functions, This below code will help to multiply matrix numbers.
Program Coding
#include<stdio.h>
int a[3][3],b[3][3],c[3][3],i,j,k;
int m1,m2,n1,n2;
int mul();
int disp();
main()
{
printf("Enter the size of the matrix:");
scanf("%d%d%d%d",&m1,&n1,&m2,&n2);
if(n1==m2)
{
printf("Enter the values for matrix\n");
for(i=0;i<m1;i++)
{
for(j=0;j<m1;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the values of the matrix B:");
for(i=0;j<m2;j++)
{
for(j=0;j<n2;j++)
{
scanf("%d",&b[i][j]);
}
}
}
mul();
}
int mul()
{
printf("Matrix multiplication is \n");
for(i=0;i<m1;i++)
{
for(j=0;j<n1;j++)
{
For(k=0;k<m2;k++)
{
C[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
}
}
disp();
}
int disp()
{
for(i=0;i<m1;i++)
{
for(j=0;j<m2;j++)
{
printf("%d",c[i][j]);
}
printf("\n");
}
}
..
Compile C source as cgi
How to execute C binary as cgi script?
Compile C source as cgi
You can execute a C source as a cgi script on web servers. To do so follow the steps given below. CGI scripts are nothing but perl script.
C Source - Save the C program as text.c
#include <stdio.h>
int main(void) ..