i know this is 2 easy for you guys, but please help..... Its been only 2 wks since i enrolled this class and they gave me this assignment.... please check if its correct. thank you so much

using namespace std;

char vowels[]={a,e,i,o,u};
char n;

char main()
cout<<“Please Enter a Character:\n”;
if (n=vowels)
       cout<<“n is a VOWEL\n”;
       cout<<“n is CONSONANT\n”;
return 0;
Re: please help 80 80

I am a begginer also but I believe you need main to be declared as

int main()

The line

char vowels[]={a,e,i,o,u};

isn't needed.
I would put

char n;

inside int main().
For your branching statement you would declare each of the vowels in the condition statement i.e.

if (n == 'A' || n== 'a' || n == 'E' || ect...)

It would probably be a lot easier to use a switch statement though. i.e.

switch (n)
    case 'A':
    case 'a':
    case 'E':
    case 'e':
    case 'I':
    case 'i':
    case 'O':
    case 'o':
    case 'U':
    case 'u':
              cout << "This letter is a Vowel." << endl;
            cout << "This letter is a consonant." << endl;

Only problem with this is that if someone enters something that is not an alphabet it will be considered a consonant.

Re: please help 80 80

Welcome to Daniweb. I see that Wolfpack helped formating your code since it was your first post. In the future please use code tags when posting information, like code, where you want to preserve indentation.

As another alternative you could use the array and a loop to read through array to check if the given char is a vowel or not. Of course this assumes you know about accessing elements of an array and control loops, etc.

Note how Boldgamer refers to single chars using single quotes before and after the char, and how Bolgamer used the == operator rather than the = operator for equals.

Trying to avoid global variables is considered good form in standard C++.

Re: please help 80 80

thank you so much for your help... it really helps in understanding some of the concepts..... and their functions. :)

Be a part of the DaniWeb community

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