The following program is not giving the desired output. No warning is being shown. i am using an ide named "dev c++" . My main concern is to perform this operation on floating point no.s . But i am presently struck at integer itself. So please help me out
1)To get an output out of this
2)Suggest something to workout this on float no.s too..
thank you...
Code:
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fp,*f2;
int i,n,x[100],num;
int add,mul,y[10];
int h[10]={5,2,3,6,1};
printf("contents of DATA file");
fp=fopen("DATA.c","w");
/*writing integers as an array into "data" file*/
for(i=0;i<100;i++)
{
n=i;
x[n]=2*i;
putw(x[n],fp);
}
/*printing the written data*/
while ((num=getw(fp))!=EOF)
printf("%d",num);
fclose(fp
);
fp=fopen("DATA.c","r");
f2=fopen("result.c","w");
/*using the file "data" for further processing*/
while((num==getw(fp))!=EOF)
{
/*logic for convolution*/
for(n=0;n<=104;n++)
{
add=0;
for(i=0;i<=n;i++)
{
mul=num*h[n-i];// hope 'num' holds the values of "data" file
add=mul+add;
}
y[n]=add;
putw (y[n],f2);
}
}
fclose(fp);
fclose(f2);
/*printing the contents of file "result"*/
f2=fopen("result.c","r");
while((num=getw(f2))!=EOF)
printf("%d",num);
fclose(f2);
}