You are on page 1of 2

CIRCULAR CONVOLUTION

#include<stdio.h>
main()
{
int i,j,x[10],h[10],y[10],m,n1,n2,N,c;

printf("enter the size of first array\n");


scanf("%d", &n1);
printf("enter the size of second array\n");
scanf("%d", &n2);

printf("enter the elements of first array\n");


for(i=0;i<=n1-1;i++)
scanf("%d", &x[i]);

printf("enter the elements of second array\n");


for(i=0;i<=n2-1;i++)
scanf("%d", &h[i]);

N=n1>n2?n1:n2;

for(i=n1;i<=N-1;i++)
x[i]=0;

for(i=n2;i<=N-1;i++)
h[i]=0;

for(i=0;i<=N-1;i++)
y[i]=0;

for(m=0;m<=N-1;m++)
{
for(j=0;j<=N-1;j++)
{
c=m-j;
if (c<0)
y[m]+=x[j]*h[m-j+N];
else
y[m]+=x[j]*h[m-j];
}
}
for(i=0;i<=N-1;i++)
printf("%d\n",y[i]);
}

You might also like