Tuesday, October 11, 2011

WRITE A C++ PROGRAM TO WRITE NUMBERS FROM 1 TO 100 IN A FILE

This program is using filing concept, and will make a file called notes.txt and generate numbers from 1 to 100 using for loop.

#include<iostream>
#include<fstream>
using namespace std;
main()
{
      ofstream myFile;
      myFile.open("Notes.txt", ios::app);
      for(int i=1; i<=100; i++)
      {
              myFile<<i<<" ";
      }
      myFile.close();
system("pause");
}

No comments:

Post a Comment