Sunday, January 26, 2014

C Program to Perform Linear Convolution Using CCstudio and C Compiler

with 0 Comment
%Program to Perform Linear Convolution in CCstudio and Turbo C++ Compiler.

#include<stdio.h>
#include<conio.h>
void main()
{
int x[15]={0},y[15]={0},h[15]={0},n1,n2,n,i,j;
printf("Enter the No.of Samples of x(n)");
scanf("%d",&n1);
for(i=0;i<n1;i++)
{
printf("Enter the %d th sample",i+1);
scanf("%d",&x[i]);
}
printf("Enter the No.of Samples of h(n)");
scanf("%d",&n2);
for(i=0;i<n2;i++)
{
printf("Enter the %d th sample",i+1);
scanf("%d",&h[i]);
}
n=n1+n2-1;
printf("The Resultant Sequence is");
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
y[i]=y[i]+x[j]*h[i-j];
printf("%d",y[i]);
}
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive