Program takes a string and calculates the number of vowels, digits and white spaces

Calculates the Number of Vowels, Digits and White Spaces

Write program takes a string object from the user and calculates the number of vowels, digits and white-spaces

Object: Write a Program takes a string and calculates the number of vowels, digits and white spaces.

Code:

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string tex;
int i,vol,dig,whtsp;
vol=dig=whtsp=0;
cout<<“Writer any string: “;
getline(cin,tex);
for(i=0;tex[i]!=’\0′;i++)
{
if(tex[i]==’a’||tex[i]==’e’||tex[i]==’i’||tex[i]==’o’||tex[i]==’u’||tex[i]==’A’||tex[i]==’E’||tex[i]==’O’||tex[i]==’U’)
{
vol++;
}
else if(tex[i]>=’0’&&tex[i]<=’9′)
{
dig++;
}
else if(tex[i]==’ ‘)
{
whtsp++;
}
}
cout<<“Vowels in this string: “<<vol<<endl;
cout<<“\nDigits in this string: “<<dig;
cout<<“\nWhite-Spaces in this string: “<<whtsp;
getch();
}

Output:

Program takes a string and calculates the number of vowels, digits and white spaces

 

M.A Siddiqui

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

1 Response

  1. June 14, 2020

    […] Program takes a string and calculates the number of vowels, digits and white spaces […]

Leave a Reply

Your email address will not be published. Required fields are marked *