Subscribe to Feeds

Send Your Projects To georgepj@hotmail.com

We'll Publish It With Your Name :-)

Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]

Store Odd & Even nos to a File

Click Here To Download C File Of This Program

 //PROGRAM TO STORE ODD & EVEN NOS FROM A FILE DATA  
//Downloaded from www.c4cprog.co.nr
#include<stdio.h>
void main()
{
int c=0;
FILE *f,*f1,*f2;
f=fopen("DATA","w");
clrscr();
printf("\nEnter Nos : \n");
while(scanf("%d",&c)!=EOF)
putw(c,f);
fclose(f);
f=fopen("DATA","r");
f1=fopen("EVEN","w");
f2=fopen("ODD","w");
while((c=getw(f))!=EOF)
{
if(c%2==0)
putw(c,f1);
else
putw(c,f2);
}
fclose(f);
fclose(f1);
fclose(f2);
f1=fopen("EVEN","r");
f2=fopen("ODD","r");
printf("\n\nEVEN NOS : \n");
while((c=getw(f1))!=EOF)
printf("\n%d",c);
printf("\n\nODD NOS : \n");
while((c=getw(f2))!=EOF)
printf("\n%d",c);
getch();
}
/*
OUTPUT
Enter Nos :
2
4
8
7
6
5
^Z
EVEN NOS :
2
4
8
6
ODD NOS :
7
5
*/

0 comments:

Post a Comment