class STUDENT that contains records in a school.write a c++ programme
Answers
Answered by
1
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
class student
{
int rno;
char name[20];
float mark;
public:
void get()
{
cout<<“\nEnter data: Roll no Name Marks\n”;
cin>>rno>>name>>mark;
}
void disp()
{
cout<<“\nRoll no\tName\tMarks\n”;
cout<<“=============================\n”;
cout<<rno<<“\t”<<name<<“\t”<<mark<<endl;
}
};
void main()
{
fstream f;
f.open(“school.dat”,ios::in|ios::out);
student s;
s.get();
f.write((char*)&s,sizeof(s));
while(f.read((char*)&s,sizeof(s)));
s.disp();
getch();
}
#include<fstream.h>
#include<conio.h>
class student
{
int rno;
char name[20];
float mark;
public:
void get()
{
cout<<“\nEnter data: Roll no Name Marks\n”;
cin>>rno>>name>>mark;
}
void disp()
{
cout<<“\nRoll no\tName\tMarks\n”;
cout<<“=============================\n”;
cout<<rno<<“\t”<<name<<“\t”<<mark<<endl;
}
};
void main()
{
fstream f;
f.open(“school.dat”,ios::in|ios::out);
student s;
s.get();
f.write((char*)&s,sizeof(s));
while(f.read((char*)&s,sizeof(s)));
s.disp();
getch();
}
Similar questions