//Program to calculate the number of vowels
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include <ctype.h>
void CHARTYPE(char STRING[20]);
void main ()
{clrscr();
char string[20],ch;
cout<<"\n Enter a string:";
gets(string);
CHARTYPE(string);
getch();
}
void CHARTYPE(char string[20])
{char ch;
int len,v=0,c=0,o=0,d=0;
for(len=0;string[len]!='\0';++len)
{if(isalpha (string[len]))
{ch=toupper(string[len]);
if(ch=='A'||ch=='E'||ch=='I'||ch=='0'||ch=='U')
++v;
else
++c ;
}
else if (isdigit (string[len]))
++d;
else
++o;
}
cout<<"\n There are "<<v<<"vowels,"<<c<<"constants,"<<d<<"digit and"<<o<<"other character in the given string :";
}
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include <ctype.h>
void CHARTYPE(char STRING[20]);
void main ()
{clrscr();
char string[20],ch;
cout<<"\n Enter a string:";
gets(string);
CHARTYPE(string);
getch();
}
void CHARTYPE(char string[20])
{char ch;
int len,v=0,c=0,o=0,d=0;
for(len=0;string[len]!='\0';++len)
{if(isalpha (string[len]))
{ch=toupper(string[len]);
if(ch=='A'||ch=='E'||ch=='I'||ch=='0'||ch=='U')
++v;
else
++c ;
}
else if (isdigit (string[len]))
++d;
else
++o;
}
cout<<"\n There are "<<v<<"vowels,"<<c<<"constants,"<<d<<"digit and"<<o<<"other character in the given string :";
}
Program to enter a poem and calculate number of vowel and consonants in string
Characters Monday, March 02, 2020//program to enter a poem and to calculate number of vowel and consonants
#include<fstream.h>
#include<conio.h>
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<stdio.h>
void main()
{ clrscr();
char ch[100],charc,charw[10];
int count1=0,count2=0;
ofstream ofile;
ofile.open("POEM.TXT",ios::out);
if(!ofile)
{ cout<<"\n File can't be open";
exit(1);
}
cout<<"\n Enter the poem:";
gets(ch);
ofile<<ch;
ofile.close();
ifstream ifile, ifile1;
ifile.open("POEM.TXT",ios::in);
if(!ifile)
{ cout<<"\n File can not read";
exit(1);
}
while(ifile>>charc)
{ charc=toupper(charc);
if(charc=='A'||charc=='E'||charc=='I'||charc=='O'||charc=='U')
count1++;
}
cout<<"\n Number of vowel="<<count1;
ifile.close();
ifile1.open("POEM.TXT",ios::in);
if(!ifile1)
{ cout<<"\n File can not read";
exit(1);
}
while(ifile1)
{ ifile1>>charw;
if(strcmpi(charw,"the")==0)
count2++;
}
cout<<"\n Number of 'the'="<<count2;
ifile1.close();
getch();
}
#include<fstream.h>
#include<conio.h>
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<stdio.h>
void main()
{ clrscr();
char ch[100],charc,charw[10];
int count1=0,count2=0;
ofstream ofile;
ofile.open("POEM.TXT",ios::out);
if(!ofile)
{ cout<<"\n File can't be open";
exit(1);
}
cout<<"\n Enter the poem:";
gets(ch);
ofile<<ch;
ofile.close();
ifstream ifile, ifile1;
ifile.open("POEM.TXT",ios::in);
if(!ifile)
{ cout<<"\n File can not read";
exit(1);
}
while(ifile>>charc)
{ charc=toupper(charc);
if(charc=='A'||charc=='E'||charc=='I'||charc=='O'||charc=='U')
count1++;
}
cout<<"\n Number of vowel="<<count1;
ifile.close();
ifile1.open("POEM.TXT",ios::in);
if(!ifile1)
{ cout<<"\n File can not read";
exit(1);
}
while(ifile1)
{ ifile1>>charw;
if(strcmpi(charw,"the")==0)
count2++;
}
cout<<"\n Number of 'the'="<<count2;
ifile1.close();
getch();
}
Program to maintain the record and details of candidates | C++ Programming
Data Record Sunday, March 01, 2020//program to maintain the record of candidates
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class CANDIDATE
{ int CRNo;
char Name[10] ;
float Score;
char Grade;
void ComputeGrade();
public:
CANDIDATE()
{CRNo =0;
strcpy(Name,"Not Assigned");
Score=0.0;
Grade='-';
}
void inputdata();
void displaydata();
};
void CANDIDATE::inputdata()
{ cout<<"\n ENTER CRNo. :";
cin>>CRNo;
cout<<"\n ENTER YOUR NAME :";
gets(Name);
cout<<"\n ENTER YOUR SCORE:";
cin>>Score;
ComputeGrade();
}
void CANDIDATE::displaydata()
{ cout<<"\n\n\t CRNo = "<<CRNo
<<"\n\t NAME ="<<Name
<<"\n\t SCORE ="<<Score
<<"\n\t Grade ="<<Grade;
}
void CANDIDATE::ComputeGrade()
{ if(Score>=90)
Grade='A';
else if(Score>=75)
Grade='B';
else if(Score>=60)
Grade='C';
else if(Score>=45)
Grade='D';
else if(Score>=33)
Grade='E';
else
Grade='F';
}
void main()
{clrscr();
int i,pno;
CANDIDATE obj[2];
cout<<"\n ENTER THE DETAILS OF THE CANDIDATE";
for(i=0;i<2;i++)
{ cout<<"\n ENTER THE DETAILS OF THE CANDIDATE No "<<i+1;
obj[i].inputdata();
}
for(i=0;i<2;i++)
{obj[i].displaydata();
getch();
}
getch();
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class CANDIDATE
{ int CRNo;
char Name[10] ;
float Score;
char Grade;
void ComputeGrade();
public:
CANDIDATE()
{CRNo =0;
strcpy(Name,"Not Assigned");
Score=0.0;
Grade='-';
}
void inputdata();
void displaydata();
};
void CANDIDATE::inputdata()
{ cout<<"\n ENTER CRNo. :";
cin>>CRNo;
cout<<"\n ENTER YOUR NAME :";
gets(Name);
cout<<"\n ENTER YOUR SCORE:";
cin>>Score;
ComputeGrade();
}
void CANDIDATE::displaydata()
{ cout<<"\n\n\t CRNo = "<<CRNo
<<"\n\t NAME ="<<Name
<<"\n\t SCORE ="<<Score
<<"\n\t Grade ="<<Grade;
}
void CANDIDATE::ComputeGrade()
{ if(Score>=90)
Grade='A';
else if(Score>=75)
Grade='B';
else if(Score>=60)
Grade='C';
else if(Score>=45)
Grade='D';
else if(Score>=33)
Grade='E';
else
Grade='F';
}
void main()
{clrscr();
int i,pno;
CANDIDATE obj[2];
cout<<"\n ENTER THE DETAILS OF THE CANDIDATE";
for(i=0;i<2;i++)
{ cout<<"\n ENTER THE DETAILS OF THE CANDIDATE No "<<i+1;
obj[i].inputdata();
}
for(i=0;i<2;i++)
{obj[i].displaydata();
getch();
}
getch();
}
Program to count uppercase, lowercase, digits and other characters | C++ Programming
Characters Saturday, February 29, 2020//program to count uppercase,lowercase,digits and other charcters
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
void COUNT(char str[20]);
void main()
{clrscr();
char string[20];
cout<<"\n Enter a string: ";
gets(string);
COUNT(string);
getch();
}
void COUNT(char str[20])
{int upper=0,lower=0,digit=0,other=0;
for(int i=0; str[i]!='\0'; i++)
{
if(isupper(str[i]))
upper++;
else if(islower(str[i]))
lower++;
else if(isdigit(str[i]))
digit++;
else
other++;
}
cout<<"\n Number of uppercase characters = "<<upper;
cout<<"\n Number of lowercase characters = "<<lower;
cout<<"\n Number of digits = "<<digit;
cout<<"\n Number of other characters = "<<other;
}
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
void COUNT(char str[20]);
void main()
{clrscr();
char string[20];
cout<<"\n Enter a string: ";
gets(string);
COUNT(string);
getch();
}
void COUNT(char str[20])
{int upper=0,lower=0,digit=0,other=0;
for(int i=0; str[i]!='\0'; i++)
{
if(isupper(str[i]))
upper++;
else if(islower(str[i]))
lower++;
else if(isdigit(str[i]))
digit++;
else
other++;
}
cout<<"\n Number of uppercase characters = "<<upper;
cout<<"\n Number of lowercase characters = "<<lower;
cout<<"\n Number of digits = "<<digit;
cout<<"\n Number of other characters = "<<other;
}




