C++/c++

Advertisement


Question
how do u count vowels in a string using a c++ program?

Answer
Hi Priyanka

#include<stdio.h>
void main()
{
int count = 0, i;
char str[100];
cout<<"Enter a String: ";
gets(str);
for(i=0;str[i]!='\0';i++)
if(str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U' || str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u')
count++;
cout<<"No of vowels: "+count;
}

please try out this code and in case of any problem please get back to me.

regards
Joydeep Bhattacharya
http;//www.scodz.com

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

TSR, Socket and Very Complex Mathematical Problem

Experience

Worked on many OOP projects with design patterns

Organizations
http://www.scodz.com

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called http://www.scodz.com

Past/Present Clients
http://www.funforu.com http://www.dhoondho.com http://analysingc.50webs.com

©2016 About.com. All rights reserved.