source file name: oddeven.cpp


#include <iostream.h>

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include <fstream.h>


int main()

{

int num[]={12,11,-50,60,113,178,45,100,145,500};


ofstream fout1,fout2;

fout1.open("odd.txt");

fout2.open("even.txt");



clrscr();

for(int i=0;i<9;i++)

{

if(num[i]%2==0)

fout1<<num[i]<<" ";

else

fout2<<num[i]<<" ";

}

fout1.close();

fout2.close();

getch();

return 0;

}

output:
Contents of Odd.txt file


Contents of Even.txt file