#include<stdio.h>
#include<conio.h>
void
main()
{
FILE *fp1,*fp2,*fp3;
int i,num,n;
clrscr();
fp1=fopen("number.txt","w");
printf("\n Enter How Many number
U Want To Store : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n Enter Number
: ");
scanf("%d",&num);
putw(num,fp1);
}
fclose(fp1);
fp1=fopen("number.txt","r");
fp2=fopen("odd.txt","w");
fp3=fopen("even.txt","w");
printf("\n Content of NUMBER file
\n");
while((num=getw(fp1))!=EOF)
{
printf("\t
%4d",num);
if(num%2!=0)
{
putw(num,fp2);
}
else
{
putw(num,fp3);
}
}
fclose(fp2);
fclose(fp3);
// open file for reading purpose
fp2=fopen("odd.txt","r");
fp3=fopen("even.txt","r");
printf("\n-----------------------");
printf("\n Content of ODD file
\n");
while((num=getw(fp2))!=EOF)
{
printf("\t %4d",num);
}
printf("\n-----------------------");
printf("\n Content of EVEN file
\n");
while((num=getw(fp3))!=EOF)
{
printf("\t %4d",num);
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
getch();
}