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. C++ projects for beginners with source code

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...

3 Responses

  1. sql interview questions says:

    We are a group of volunteers and opening a new scheme in our community.
    Your web site offered us with valuable info to work on. You’ve done an impressive job and our entire
    the community will be grateful to you.

  2. behavioral interview questions says:

    Great information. Lucky me I came across your site by chance.
    I have saved it for later!

  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 *