oops assignment 1 cs4

 QUESTION 1:


#include <iostream>

#include <string>
using namespace std;
class student{
private:
string name;
int roll_no;
int year;
public:
void accept(void);
void print(void);

};
void student :: accept(void){
    cout<<"Enter name of student :"<<endl;
    cin>>name;
    cout<<"Enter roll no of student : "<<endl;
    cin>>roll_no;
    cout<<"Enter year of student : "<<endl;
    cin>>year;
}
void student :: print(void){
cout<<"name of student : "<<name<<endl;
cout<<"Roll no : "<<roll_no<<endl;
cout<<"Year of student : "<<year<<endl;

}
int main()
{

cout<<"Enter details of student"<<endl;

student std1,std2,std3;
std1.accept();
std2.accept();
std3.accept();

cout<<"Details of student is : "<<endl;

std1.print();
std2.print();
std3.print();

    return 0;
}    

output:

PS D:\oops> .\asignment1.cpp PS D:\oops> .\asignment1.exe Enter details of student Enter name of student : shivam Enter roll no of student : 23 Enter year of student : 2023 Enter name of student : sourabh Enter roll no of student : 24 Enter year of student : 2023 Enter name of student : sudhanshu Enter roll no of student : 56 Enter year of student : 2022 Details of student is : name of student : shivam Roll no : 23 Year of student : 2023 name of student : sourabh Roll no : 24 Year of student : 2023 name of student : sudhanshu Roll no : 56 Year of student : 2022 PS D:\oops>


QUESTION 2 :


No comments:

Post a Comment