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 to illustrate the use of parameterless function

  2. Program that list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters

  3. Program to reverse the content of an integer array

  4. Program to perform insertion sort

  5. Program that prints odd numbers, even numbers and the numbers that are divisible by 5 b/w 0 to 50

  6. Program to illustrate the operations that can be performed on pointers

  7. CREATING A CLASS ACCOUNTS FROM WHICH ARE DERIVED TWO CLASSES CURRENT AND SAVINGS AND THEN ASK THE USER FOR THE TYPE OF ACCOUNT HE WANTS TO CREATE

  8. Program to show the 3D Reflection Transformation along xy-plane

  9. Program to illustrate the implementation of arrays as a Linear Queue

  10. Program that reads a number and prints even if the number is even and prints odd if the number is odd.

  11. Program to solve the Towers of Hanoi Problem (using Recursive Algorithm)

  12. Program to sort that set of strings in ascending and descending order of their weights. The sorted output is to be displayed on the screen

  13. Program for Operator Overloading and Friend Function concept

  14. Program to print some text

  15. Program to show the implementation of None-or-All Character Clipping Strategy (Text Clipping Example)

  16. Program of Bresenham line drawing algorithm

  17. Program of converting class type to basic variable of type string using conversion function

  18. Program that reads a number and displays it with its digits in reverse order using do-while loop

  19. Program to generate a triangular wave form according to a specified pair of Amplitude and Frequency

  20. To parse a string using Operator Precedence parsing

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