www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS201 Assignment#4 Idea Solution & Discussion

Solution:-

#include <iostream>
using namespace std;
class Student{
private:
string name;
int rollNumber;
string semester;
double cgpa;

public:
Student(string n,int r,string s,double c )
{name=n;
rollNumber=r;
semester=s;
cgpa=c;
}
Student()
{name="";
rollNumber=0;
semester="Summer 2010";
cgpa=4.0;
}

string get_semester()
{return semester;
}
void set_semester(string n)
{semester=n;
}
void set_roll(int n)
{rollNumber=n;
}
int get_roll()
{return rollNumber;
}
void set_name(string n)
{name=n;
}
string get_name()
{return name;
}
void set_cgpa(double n)
{cgpa=n;
}

double get_cgpa()
{return cgpa;
}
void print()
{cout"Student Information\n";
cout"Name: "nameendl;
cout"Roll number: "rollNumberendl;
cout"Semester: "semesterendl;
cout"Current GPA: "cgpaendlendl;
}
};

int main()
{Student a;
Student b("name",2345,"Spring 2010",3.5);
a.print();
b.print();
system("pause");
return 0;
}

Views: 266

### Replies to This Discussion

plz jaldey jawab dein . Siraf Allah hey ebadat kay laiq hein .
Problem during compiling .........
is mein kahan correction key zaroorat hay . plz jaldey jawab dein.
Include the header file #include "string" with angle brackets, coz only that file hold this data type and it's definition. OMG! all the member functions declared in this class are working like inline functions. You guys should define all the function explicitly and only their prototypes will be included in the class.Then it will work fine, addios amigoes!
hahhahaahahah.........
Problem of assignment "The system can not find the file specified"
if problem in coding ....... follow the errors and correct
Assignemnt cs201-04 output
Attachments:
han bhai...... iss program mai problem hai...

plz check it...... and upload the update program

aaj last date hai....... :((
Thanks for help in Assigment solution
some one check it plz.. and tell me is it ok.. ??
it gives me result, but i am not shure on this program..

---------------------------------------------------------

#include
using namespace std;
class Student{
private:
string name;
int rollNumber;
string semester;
double cgpa;

public:
Student(string n,int r,string s,double c )
{name=n;
rollNumber=r;
semester=s;
cgpa=c;
}
Student()
{name="";
rollNumber=0;
semester="Summer 2010";
cgpa=4.0;
}

string get_semester()
{return semester;
}
void set_semester(string n)
{semester=n;
}
void set_roll(int n)
{rollNumber=n;
}
int get_roll()
{return rollNumber;
}
void set_name(string n)
{name=n;
}
string get_name()
{return name;
}
void set_cgpa(double n)
{cgpa=n;
}

double get_cgpa()
{return cgpa;
}
void print()
{
cout"Student Information\n";
cout"Kamal Khan "endl;
cout"MC100200133 "endl;
cout"1st "endl;
cout"3.5 "endl;
}
};

int main()
{Student a;
Student b("name",2345,"Spring 2010",3.5);
a.print();
b.print();
system("pause");
return 0;
}
#include
using namespace std;
class Student{
private:
string name;
int rollNumber;
string semester;
double cgpa;

public:
Student(string n,int r,string s,double c )
{name=n;
rollNumber=r;
semester=s;
cgpa=c;
}
Student()
{name="";
rollNumber=0;
semester="Summer 2010";
cgpa=2.3;
}

string get_semester()
{return semester;
}
void set_semester(string n)
{semester=n;
}
void set_roll(int n)
{rollNumber=n;
}
int get_roll()
{return rollNumber;
}
void set_name(string n)
{name=n;
}
string get_name()
{return name;
}
void set_cgpa(double n)
{cgpa=n;
}

double get_cgpa()
{return cgpa;
}
void print()
{cout"Student Information\n";
cout"Name: "nameendl;
cout"Roll number: "rollNumberendl;
cout"Semester: "semesterendl;
cout"Current GPA: "cgpaendl;
}

};

int main()
{Student a;
Student b("name",2345,"Spring 2010",3.5);
a.print();
b.print();
system("pause");
return 0;
}

1

2

3

4

5

## VIP Member Badge & Others

------------------------------------

## Latest Activity

aisha, zaniab, Iqra Mubashir and 2 more joined Virtual University of Pakistan
1 hour ago
Dream♥Girl joined + M.Tariq Malik's group

### CS606 Compiler Construction

7 hours ago
7 hours ago
Asad waqas added a discussion to the group PSY101 Introduction to Psychology

### PSY101 Final Term Important Topic & Past Papers 2018 to 2021 || psy101 final term important topic

10 hours ago
11 hours ago
11 hours ago
Meera ch and + Ḱẚảḿḯ are now friends
11 hours ago
Sɩɗɗo Rʌjpoot is now friends with Mr Siren Head, Golden Eye, Elegant and Ayaan more
12 hours ago