This program is for implementing Walsh Matrix. This is a part of Mumbai University MCA Colleges Data Communication and Networking MCA Sem 4
#include <stdio.h>
#include <conio.h>
#include <math.h>
int walsh[8][8]={1};
int walshnxt[8][8]={0};
void copy(int cnt)
{
int i, j, k;
for(i=0; i<cnt; i++)
{
for(j=0; j<cnt/2; j++)
{
if(i < cnt/2)
{
walshnxt[i][j]=walsh[i][j];
walshnxt[i][j+(cnt/2)]=walsh[i][j];
}
else
{
k=i-(cnt/2);
walshnxt[i][j]=walsh[k][j];
if(walsh[k][j] == 1)
walshnxt[i][j+(cnt/2)]=-1;
else
walshnxt[i][j+(cnt/2)]=1;
}
}
}
for(i=0; i<7; i++)
{
for(j=0; j<7; j++)
{
walsh[i][j]=walshnxt[i][j];
}
}
}
void main()
{
int num, i, j, cntr;
clrscr();
printf("Enter the power of 2: ");
scanf("%d", &num);
walsh[0][0]=1;
cntr=1;
for(i=2; i <= pow(2, num);i=pow(2, cntr))
{
copy(i);
cntr++;
}
printf("\n\n\n");
if(num==0)
printf("\t1");
else
for(i=0;i<pow(2,num);i++)
{
for(j=0;j<pow(2,num);j++)
{
printf("\t %d", walshnxt[i][j]);
}
printf("\n");
}
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
#include <stdio.h>
#include <conio.h>
#include <math.h>
int walsh[8][8]={1};
int walshnxt[8][8]={0};
void copy(int cnt)
{
int i, j, k;
for(i=0; i<cnt; i++)
{
for(j=0; j<cnt/2; j++)
{
if(i < cnt/2)
{
walshnxt[i][j]=walsh[i][j];
walshnxt[i][j+(cnt/2)]=walsh[i][j];
}
else
{
k=i-(cnt/2);
walshnxt[i][j]=walsh[k][j];
if(walsh[k][j] == 1)
walshnxt[i][j+(cnt/2)]=-1;
else
walshnxt[i][j+(cnt/2)]=1;
}
}
}
for(i=0; i<7; i++)
{
for(j=0; j<7; j++)
{
walsh[i][j]=walshnxt[i][j];
}
}
}
void main()
{
int num, i, j, cntr;
clrscr();
printf("Enter the power of 2: ");
scanf("%d", &num);
walsh[0][0]=1;
cntr=1;
for(i=2; i <= pow(2, num);i=pow(2, cntr))
{
copy(i);
cntr++;
}
printf("\n\n\n");
if(num==0)
printf("\t1");
else
for(i=0;i<pow(2,num);i++)
{
for(j=0;j<pow(2,num);j++)
{
printf("\t %d", walshnxt[i][j]);
}
printf("\n");
}
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
Download
No comments:
Post a Comment