Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class student{
- int roll;
- public:
- void getdata() {
- cout<<"enter your roll no ";
- cin>>roll;
- }
- void display() {
- cout<<"roll no "<<roll;
- }
- };
- int main()
- {
- student s[3];
- for(int i=0 ; i<3 ; i++){
- s[i].getdata();
- s[i].display();
- cout<<"\n";
- }
- return 0;
- }
- /*
- Output
- enter your roll no 1
- roll no 1
- enter your roll no 2
- roll no 2
- enter your roll no 3
- roll no 3
- */
Advertisement
Add Comment
Please, Sign In to add comment