Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,144 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,085 people online right now. Registration is fast and FREE... Join Now!




vowels

 
Reply to this topicStart new topic

vowels, Vowel program

vyiruskiller
16 May, 2007 - 11:00 AM
Post #1

New D.I.C Head
*

Joined: 4 Oct, 2006
Posts: 14


My Contributions
Hey guys this is a program i am working on for my programming class. Arrays.. I am studying programming in Mexico. My program contains spanish words.

This program needs to pring the amount of vowels that is located in a sentence the user typed:

a=
e=
i=
o=
u=

I am having problems with that part. This rest of the program is working. My only problem is counting the single vowels themselves.
can you help me please.



#include <iostream.h>
#include <conio.h>

void main(){

clrscr();
char lectura[80];
int vocalnum,cm=0,cmin=0,vm=0,vmin=0;

cout <<"Write a sentence):\n "<<endl;
cin.getline(lectura,80);
for(int x=0; lectura[x]!='\0';x++){
if(lectura[x]=='A'||lectura[x]=='E'||lectura[x]=='I'||lectura[x]=='O'||lectura[x]=='U')
vm++;
else
if(lectura[x]=='a'||lectura[x]=='e'||lectura[x]=='i'||lectura[x]=='o'||lectura[x]=='u')
vmin++;
else
if(lectura[x]>+65&&lectura[x]<=90)
cm++;
else
if (lectura[x]>+97&&lectura[x]<=122)
cmin++;
}

cout<<"\n\n\n"<<endl;
cout<<"Uppercase Consonants = " <<cm<< endl;
cout<<"Lowercase Consonants = " <<cmin<< endl;
cout<<"Uppercase Vowels = " <<vm<< endl;
cout<<" A = "<<<<endl;
cout<<" E = "<<endl;
cout<<" I = "<<endl;
cout<<" O = "<<endl;
cout<<" U = "<<endl;
cout<<"Lowercase Vowels = " <<vmin<< endl;
cout<<" a = "<<endl;
cout<<" e = "<<endl;
cout<<" i = "<<endl;
cout<<" o = "<<endl;
cout<<" u = "<<endl;
vocalnum = vm+vmin;
cout<< "\nTotal number of vowels = " <<vocalnum<< endl;
getch();
}

This post has been edited by vyiruskiller: 16 May, 2007 - 12:12 PM
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Vowels
16 May, 2007 - 02:49 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
You've already got the idea donw...where you are currently checking several conditions for a vowel, you'll have to further check which vowel it is...example:
CODE

int vowa=0;
int vowe=0;
int vowi=0;
int vowo=0;
int vowu=0;
if(lectura[x]=='a'||lectura[x]=='e'||lectura[x]=='i'||lectura[x]=='o'||lectura[x]=='u')
{
   vmin++;
   if(lectura[x]=='a')
      vowa++;
   //and so on

Of course, this is a brute force method...you can use a switch statement to catch the conditions, if lowercase case a increment vmin and vowa, etc...
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:51PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month