:twisted:


guys can some1 give me hints to solve this? any help will do. thank you.


make a program display a lowercase vowels using do while loop:


heres my code:

char letter;
{
    do{
        cout<<letter;
    }
    while((letter!='b')||(letter!='c')||(letter!='f')||(letter!='g')||(letter!='h')||(letter!='j')||
          (letter!='k')||(letter!='l')||(letter!='m')||(letter!='n')||(letter!='p')||(letter!='q')||
          (letter!='r')||(letter!='s')||(letter!='t')||(letter!='v')||(letter!='w')||(letter!='x')||
          (letter!='y')||(letter!='z'))
}

heres my code but it won't work!

Recommended Answers

What you probably want to do is accept any character in the loop, but only print it if it matches the criteria:
[code]
while (cin >> letter) {
if (is_vowel(letter))
cout << letter;
}
[/code]
Obviously this is a non-working example that you would need to flesh out (such as …

Jump to Post

All 5 Replies

Re: do while loop need some help. :D 80 80

What you probably want to do is accept any character in the loop, but only print it if it matches the criteria:

while (cin >> letter) {
    if (is_vowel(letter))
        cout << letter;
}

Obviously this is a non-working example that you would need to flesh out (such as writing is_vowel()), but it should suffice to show the concept.

Re: do while loop need some help. :D 80 80

thanks sir, but i haven't get the idea, i have to use do-while loop. sorry i'm a newbie w/ this.

Re: do while loop need some help. :D 80 80

What do you know about the differences/similarities between the while and do-while loops?

Re: do while loop need some help. :D 80 80

1) Start letter at 'a'
2) Start the do-while loop
3) IF letter is not vowel
4) output the letter
5) increment the letter
6) end of do-while if letter >= 'z'

Re: do while loop need some help. :D 80 80
#include <iostream>
using namespace std;
int main()
{ 
char letter='a';
do { 
if((letter!='b')&&(letter!='c')&&(letter!='d')&&(letter!='f')&&(letter!='g')&&(letter!='h')&&(letter!='j')&&(letter!='k')&&(letter!='l')&&(letter!='m')&&(letter!='n')&&(letter!='p')&&(letter!='q')&&(letter!='r')&&(letter!='s')&&(letter!='t')&&(letter!='y')&&(letter!='x')&&(letter!='z')&&(letter!='w')&&(letter!='v')) 
cout<<letter; letter++; 
}while(letter<='u'); 
system ("pause"); return 0;
 } 

thanks to you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.