Home Education Cs201 Assignment 2 Solution Spring 2022

Cs201 Assignment 2 Solution Spring 2022

by Usman CB
Cs201 Assignment 2 Solution Spring 2022

Are you looking for Cs201 Assignment 2 Solution Spring 2022?  If yes Then Your Landed on the Right Place . Here you will get all about important you needed as well as This Website is for Assignment Quiz and Gdbs of Virtual University of Pakistan. 

Cs201 Assignment 2 Spring 2022

As we know the question is uploaded on the LMS.

Download Cs201 Assignment 2 Solution Spring 2022

#include<iostream>

#include<stdlib.h>

#include<cstring>

using namespace std;
class Student{
char std_id[20], vac_name[10];
int age,num_dose;
public:
Student() {
strcpy(std_id,”BC21000000“);
strcpy(vac_name,”Sinovac”);
age = 20;
num_dose = 1;
}
Student(const char id[], const char vac[], int aAge, int dose) {
strcpy(std_id,id);
strcpy(vac_name,vac);
age = aAge;
num_dose = dose;
}
void setName(const char id[]) {
strcpy(std_id,id);
}
void setVaccine(const char vac[]) {
strcpy(vac_name,vac);
}
void setAge(int A) {
age = A;
}
void setDose(int D) {
num_dose = D;
}
char* getName() {
return std_id;
}
char* getVaccine() {
return vac_name;
}
int getAge() {
return age;
}
int getDose() {
return num_dose;
}
friend void display(Student std) {
cout<<“Student ID: “<< std.std_id <<endl;
cout<<“Age: “<< std.age <<endl;
cout<<“Vaccination: “<< std.vac_name <<endl;
cout<<“Vaccination Doses: “<< std.num_dose <<endl;
}
};
int main() {
Student std1;
Student std2(“BC123456789″,”Sinopharm”,22,21);
Student std3;
std3.setName(“MC123456789”);
std3.setVaccine(“Moderna”);
std3.setAge(22);
std3.setDose(3);
cout<<“Printing std1 Object values using display() …\n”<<endl;
display(std1);
cout<<“Printing std2 Object values using display() …\n”<<endl;
display(std2);
cout<<“Printing std3 Object values using getter() method…\n”<<endl;
cout<<“Student id: “<<std3.getName()<<endl
<<“Age: “<<std3.getAge()<<endl
<<“Vaccination: “<<std3.getVaccine()<<endl
<<“Vaccination Dose: “<<std3.getVaccine()<<endl;

system(“pause>0”);

return 0;

}

Note: DOn’t Copy Paste this code but Change All those things that are mentioned in the assignment but Code is 100% ok for Cs201 Assignment 2 Solution Spring 2022!

Also Read:

CS201 Final Term Important Files By Concepts Builder

Mth101 Assignment 2 Solution Spring 2022

CS302 Final Term Important Files | CS302 Solved Files

CS301 Final Term Important Files | Mcq’s And Short Notes

Related Posts

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.