C program to create a file student.dat, C/C++ Programming

Assignment Help:

Program is to create a file student.dat:

Program is to create a file student.dat which contains all name, roll_no,marks(5 sub) and percentage

  class student

   {

   private:

    char name[20];

    int roll;

    int marks[5];

    int total;

    float perc;

   public:

    student()

     {

     total=0;

     }

     void input();

     void output();

     };

 

 void student::input()

  {

  clrscr();

  cout<<" enter your name ";

  gets(name);

  cout<<" enter your roll no. ";

  cin>>roll;

  cout<<" enter the marks of five subjects "<<"\n";

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

    {

    cout<<" enter marks";

    cin>>marks[i];

    total=total + marks[i];

    }

   }

 void student::output()

   {

   clrscr();

   perc=total/5;

    if (perc>=60)

      {

     cout<<" the name is "<

     cout<<" the total marks obtained out of (500) "<

     cout<<" the percentage "<

     }

    else

     cout<<" the percten tage is less then 60 ";

   }

 

  void main()

    {

    clrscr();

   student info;

   fstream file;

   file.open("student.dat",ios::in|ios::out);

   int n;

   cout<<" enter the number for which u want to enter data";

   cin>>n;

   for(int i=1;i<=n;i++)

     {

     info.input();

     file.write((char *)& info,sizeof(info));

     }

     file.close();

     file.open("student.dat",ios::in);

     while(file)

      {

    file.write((char *)& info,sizeof(info));

    info.output();

    }

   file.close();

   }


Related Discussions:- C program to create a file student.dat

How to define a structure, How to Define a Structure? Structure declara...

How to Define a Structure? Structure declarations are rather more complicated than array declarations, ever since a structure must be defined in terms of its individual members

Overloading unary operators, Overloading Unary Operators class sign ...

Overloading Unary Operators class sign {int a,b,c; public: sign(){}; sign(int,int,int); void putdata(void); void operator-(); }; void sign::operator-() {a=

Convert a cov-cpe file to a tif image file, Convert a COV/CPE (Micosoft Fax...

Convert a COV/CPE (Micosoft Fax Cover Page) file to a TIF image file Project Description: I would like a small API written that will take a COV/CPE file and replaced the corr

C program to add two polar coordinates, Aim: To implement a program to add...

Aim: To implement a program to add two polar coordinates using operator overloading. Code:                       #define PI 3.14 class polar {             double

Where php basically used, Why many companies are switching their current bu...

Why many companies are switching their current business language to PHP? Where PHP basically used? PHP is rapidly gaining popularity and numerous companies are switching their

Minimumshelf, Write a program that finds the minimum total number of shelve...

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

STM32F103RET6, traffic light t junction I have 21 LEDs will 6 in each side...

traffic light t junction I have 21 LEDs will 6 in each side 3 for the cars the other 3 will be for the people across the street this will be for each side and the last 3 for show

Define commonly used built-in library functions, Define Commonly Used Built...

Define Commonly Used Built-in Library Functions? Comprise opened a file pointer you will desire to use it for either input or output. The C language supplies a set of functions

Program is to reverse the names stored in an array pointer, Program is to r...

Program is to reverse the names stored in an array pointer: Program is to reverse the 6 names stored in an array pointer as name[] void main()   {  clrscr();  char

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd