C++ Programming Blog

 
 
 

Image

#include <iostream.h>
#include <fstream.h>
#include <conio.h>

static int totrec=0;    //totrec variable keep track for total variable entered
            //Initially Record scanned are Zero

void main()
{
int choice;
while(1)
{
clrscr();
cout<<\"Choose your choice\\nNOTE : one choice for one record(except viewing data)\\n\";
cout<<\"1) Scanning intial records\\n\";
cout<<\"2) Appending records\\n\";
cout<<\"3) Modifying or append records\\n\";
cout<<\"4) Viewing records\\n\";
cout<<\"5) Exit\\n\";
cout<<\"Enter your choice : \";
cin>>choice;
switch (choice)
{
  case 1 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::out);
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him\\her : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec= totrec + 1;
         outfile.close();
         }
         break;
  case 2 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::app);
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         outfile.close();
         }
         break;
  case 3 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::ate);
         cout<<\"Are you interested in adding record\\nenter y or n\\n\";
         char ans;
         cin>>ans;
         if(ans==\'y\' || ans==\'Y\')
         {
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         }
         outfile.close();
         }
         break;
  case 4 :   {
         ifstream infile;
         infile.open(\"emp\",ios::in);
         const int size=80;
         char line[size];
         int counter=totrec;
         while(counter > 0)
         {
         infile.getline(line,size);
         cout<<\"\\n\\nNAME     : \"<<line<<endl;
         infile.getline(line,size);
         cout<<\"AGE      : \"<<line<<endl;
         infile.getline(line,size);
         cout<<\"LANGUAGE : \"<<line<<endl;
         counter--;
         }
         infile.close();
         }
         getch();
         break;
  case 5  :  goto out;
  default :  cout<<\"\\nInvalid Choice\\nTRY AGAIN\\n\";
  }
}
out:
}

    Related Post:
  1. Program that reads marks obtained by a student in a test of 100 marks and print pass if marks are greater than or equal to 50

  2. Program to add, subtract, multiply, sort, search, transpose and merge matrices

  3. Program of cohen sutherland Line clipping Algorithm

  4. Program to construct and display the Divided Difference Table from the given distinct data points.

  5. Program to illustrate the implementation of arrays as a Stack

  6. Program of Graphical Representation of Stack And Queue

  7. Program that prints first 20 integers (using while loop)

  8. Program to illustrate operator overloading from class to basic type

  9. Program to illustrate the implementation of Translation Transformation

  10. Program to illustrate the difference between the use of strcomp, strcmpi and stricmp

  11. Program to illustrate unary operator increment operator overloading with return type

  12. Program to read a Non-Linear equation in one variable, then evaluate it using Secant Method and display its kD accurate root

  13. Program to estimate value of First Derivative of the function at the given points from the given data using Backward Difference Formula , Forward diff

  14. Program of class to basic conversion

  15. Program that creats a 3D solid object using Translational Sweep Representatiom Method

  16. Program to implement Add and Subtract functions on Big Number Class

  17. Program to draw a line using Cartesian Slope-Intercept Equation [ Simple Implementation ]

  18. Program to illustrate the implementation of Arithmetic Expression Evaluater accepting {} & [] also

  19. Program to illustrate passing structures to function

  20. Program to illustrate classes without using inline functions

 
 
Didn't find what you were looking for? Find more on Program that performs file read, write, update and display operations