Posts

Showing posts with the label Sequential file operation
#include<iostream> #include<fstream> using namespace std; // define a class to store student data class student {    int roll;    char name[30];    float marks; public:    student() { }    void getData(); // get student data from user    void displayData(); // display data    int getNo(){return roll;} }; void student :: getData() {    cout << "\nEnter Roll No. : ";    cin >> roll;    cin.ignore(); // ignore the newline char inserted when you press enter    cout << "Enter Name : ";    cin.getline(name, 30);    cout << "Enter Marks : ";    cin >> marks; } void student :: displayData() {    cout << "\nRoll No. : " << roll << endl;    cout << "Name : " << name << endl;    cout << "Marks : " << marks << endl; } int main() { ...