source file name: Inher11.CPP
#include<conio.h>
#include<string.h>
#include<iostream.h>
class Fact
{
public :
int fact(int n)
{
int f=1;
while(n>0)
{
f*=n;
n--;
}
return f;
}
};
class strdemo: public Fact
{
public:
void Vowels(const char *str)
{
int cost=0,sp=0,vl=0;
int len=strlen(str);
cout<<"\n "<<str;
for(int i=0;i<len;i++)
{
switch(str[i])
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':vl++;break;
case ' ': sp++;break;
}
}
cost=len-vl-sp;
cout<<" string contains : Consonants: " << cost <<" and Vowels: "<<vl;
}
};
int main()
{
int n,d;
Fact f1;
strdemo s1;
clrscr();
cout<<"\n enter any number: ";
cin>>n;
cout<<"\n factorial value is: " <<s1.fact(n);
s1.Vowels("wel come to DBJ college");
return 0;
}
output:
0 Comments
Post a Comment