If statement Problem

I'm doing an exercise in a C++ Book that asks to code a program that will determine whether a character is a vowel. I cannot seem to figure out what the problem is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

char test;

int main()
{
    std::cout << "Input an undercase character: ";
    std::cin >> test;

    if ((char == 'a') || (char == 'e') || (char == 'i') || (char == 'o') || (char == 'u'))
        std::cout << "Vowel!";

    else
	std::cout << "Not a vowel!";
    return(0);
}


That should work fine. Just use the uppercasing in the cctype first so you don't have to check upper and lower case.
What isn't working anyway?
I put char == a etc. etc. instead of the actual name test. Simple mistake I must have spent 30 minutes trying to figure out such a simple mistake haha... oo well i figured it out eventually.
On line 10, you should be testing your variable 'test' not 'char'.

EDIT: Nice work. :)
Last edited on
OH WOW
I cannot believe I missed that.
I'm ashamed.
also -- tere's no need for 'test' to be global here.

Avoid globals. They're evil.
Topic archived. No new replies allowed.