We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# CS201 Assignment No. 02 Solution & Discussion Due Date: 27-01-2014

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

Views: 6425

Attachments:

Replies are closed for this discussion.

### Replies to This Discussion

see this

complete solution CS201..

//www.vustudent.ning
#include<iostream>
#include<conio.h>
using namespace std;

class myClass
{
private :
char*str, alphabet;
public:
myClass()
{
str = new char[10];
cout"************ CS201_Assignment 02 By VUHelp.pk************ \n";
cout"\n Default Constructor is called ..... and default id is MC123456789 \n";
}
void setId(char *id)
{
str = new char[10];
strcpy(str,id);
}
char * getId()
{
return str;
}
void countfunction()
{
cout"\nEnter letter you want to count: ";
cin>>alphabet;
int i =0, count = 0;
while(str[i] != '\0')
{
if(alphabet == str[i])
{
count++;
}
i++;
}
cout"The total letters "alphabet" in your student id : "countendl;
}
~myClass()
{
delete[]str;
cout"\nDestructor called ...... and object has destroyed \n";
cout"Press any key to continue ..... ";
getch();
}
};
main()
{
myClass obj;
obj.setId("MC123456789");
obj.countfunction();
//www.vustudent.ning

OutPut:
}

Attachments:

CS201 Complete and Final solution without any error
#include<iostream>
#include<conio.h>
using namespace std;

class myClass
{
private :
char*str, alphabet;
public:
myClass()
{
str = new char[10];
cout"\n Default Constructor is called ..... and default id is MC----- \n";
}
void setId(char *id)
{
str = new char[10];
strcpy(str,id);
}
char * getId()
{
return str;
}
void countfunction()
{
cout"\nEnter letter you want to count: ";
cin>>alphabet;
int i =0, count = 0;
while(str[i] != '\0')
{
if(alphabet == str[i])
{
count++;
}
i++;
}
cout"The total letters "alphabet" in your student id : "countendl;
}
~myClass()
{
delete[]str;
cout"\nDestructor called ...... and object has destroyed \n";
cout"Press any key to continue ..... ";
getch();
}
};
main()
{
myClass obj;
obj.setId("MC--------");
obj.countfunction();
}

## Latest Activity

10 seconds ago
+M.Tariq Malik added a discussion to the group PSY632 Theory & Practice of Counseling

### PSY632 Theory & Practice of Counseling Assignment 01 Fall 2020 Solution / Discussion

54 seconds ago
1 minute ago
+M.Tariq Malik added a discussion to the group PSY512 Gender Issues in Psychology

### PSY512 Gender Issues in Psychology Assignment 01 Fall 2020 Solution / Discussion

2 minutes ago
9 minutes ago
9 minutes ago
+M.Tariq Malik added a discussion to the group ENG502 Introduction to Linguistics

### ENG502 Introduction to Linguistics GDB No 01 Fall 2020 Solution / Discussion

10 minutes ago
12 minutes ago
13 minutes ago
+M.Tariq Malik added a discussion to the group SOC101 Introduction to Sociology

### SOC101 Introduction to Sociology Assignment 01 Fall 2020 Solution / Discussion

13 minutes ago
17 minutes ago
17 minutes ago
Junaid [MAF] and Ali Fahad joined +M.Tariq Malik's group

28 minutes ago
42 minutes ago
HAFIZA AREESHA ASLAM added 2 discussions to the group ECO403 Macroeconomics
48 minutes ago
HAFIZA AREESHA ASLAM replied to HAFIZA AREESHA ASLAM's discussion first assignment in the group ECO402 Microeconomics
57 minutes ago
HAFIZA AREESHA ASLAM added a discussion to the group ECO402 Microeconomics

### first assignment

58 minutes ago
M Abid Inayat, Ayesha, Rabi Rajput and 13 more joined Virtual University of Pakistan
1 hour ago
1 hour ago
Anmol Mughal and Saarim are now friends
2 hours ago