Completely Solved C, C++ Programs Assignment.




C Program to create a file of number and copy odd number into second file and even number into third file.

Filed Under:

Problem 70. C Program to create a file of number and copy odd number into second file and even number into third file.
#include<stdio.h>
#include<conio.h>
main( )
{
FILE *fp1,*fp2,*fp3;
int i;
fp1=fopen(“DATA1”,”w”);
printf(“enter the number”);
scanf(“%d”,&i);
while(i!=eof( ))
{
putw(i,fp1);
}
fcolse(fp1);
fp1=fopen(“DATA1”,”r”);
fp2=fopen(“DATA2”,”w”);
fp3=fopen(“DATA3”,”w”);
while((i=getw(fp1))!=EOF())
if(i%2= =0)
putw(i,fp3);
else
putw(i,fp2);
fcolse(fp1);
fcolse(fp2);
fcolse(fp3);
getch( );
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments