: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

All 5 Replies

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.

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

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

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'

#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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.