cpp program to load and store records of N students.

#include<iostream.h>
#include<conio.h>
#define N 5
//apply following code for floating point operation in loop.
/*
void dummy(float *a){
float b=*a;
dummy(&b);
}
*/
class student{
int rollno;
char name[20];
float marks;
int count;
public:
student(){
count=0;
}
void getstudent();
void setstudent();
};
void student::getstudent(){
cout<<"Student Detail:-"<<endl;
cout<<"Rollno="<<rollno<<endl<<"name="<<name<<endl<<"marks="<<marks<<endl<<"object count="<<count<<endl;
}
void student::setstudent(){
cout<<"Enter Student Details:-"<<endl;
cout<<"Enter Rollno"<<endl;
cin>>rollno;
cout<<"Enter name"<<endl;
cin>>name;
cout<<"Enter marks"<<endl;
cin>>marks;
count++;
}
void main(){
student s[N];
clrscr();
for(int i=0;i<N;i++)
s[i].setstudent();
for(int i=0;i<N;i++)
s[i].getstudent();
getch();
}

No comments:

Post a Comment