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

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();

   }

Posted Date: 10/19/2012 5:39:41 AM | Location : United States







Related Discussions:- C program to create a file student.dat, Assignment Help, Ask Question on C program to create a file student.dat, Get Answer, Expert's Help, C program to create a file student.dat Discussions

Write discussion on C program to create a file student.dat
Your posts are moderated
Related Questions
Goal: Design a program that computes square matrix multiplication on GPU using CUDA. Write the code in C. In particular, your implementation should obey the following requiremen

Write a program called Series that will print/display a series of numbers starting with 1 and ending with the last number that is less than 30. The series should include only odd n

store the name of the political parties and the corresponding votes in two lists of equal length. access the lists is provided by two methods, each of which creates an interator th



Write a function for finding out highest and lowest marks obtained by a student from an array contained student name and marks. For Example : GetHighestLowestMarks{Student{n}, Ma

What is a hash function? Hash function: This is the method from the set 'K' of keys into the set 'L' of memory addresses.   H: K → L These are used to verify the address

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

Explain the For Loop - Computer Programming? Similar to the while statement, for loop is an entry controlled loop and the code of the for loop will be executed itereatively. Th

Ask question # Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particu