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

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: 6446

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

6 minutes ago
6 minutes ago
+ M.Tariq Malik added a discussion to the group MCM601 Media Management

### MCM601 Assignment No 02 Fall 2020 Solution / Discussion

7 minutes ago
12 minutes ago
12 minutes ago
+ M.Tariq Malik added a discussion to the group MCM501 Advertising for Print and Electronic Media

### MCM501 Assignment No 02 Fall 2020 Solution / Discussion

13 minutes ago
18 minutes ago
+ ⵑⵑ ӍᎥŞŞ ⲤһᵘʳһშᎥⵏ ⵑⵑ + liked + Ehtisham +'s discussion یوں ہی بے سَبب
28 minutes ago
31 minutes ago
35 minutes ago
35 minutes ago
36 minutes ago

1

2

3

4

5