here is a c++ code .. It compiles fine and looks fine but it messes up the output.

#include<iostream>
#include<string>
using namespace std;

int main() {

        string s;
        cin>>s;

        for(int i=0;i<s.length();i++) {
            if (isalpha (s[i]))
                if (s[i] == 'a'||'A'||'e'||'E'||'i'||'I'||'o'||'O'||'u'||'U')
                        cout<<s[i]<<" is a vowel"<<endl;
                else
                        cout<<s[i]<<" is a consonant"<<endl;

                 if (isdigit (s[i]))
                        cout<<s[i]<<" is a digit"<<endl;
                else
                        cout<<s[i]<<" is a special character"<<endl;
        }
}
~                                                                                                                                          
~

Can someone tell me where I am going wrong please ?

> if (s == 'a'||'A'||'e'||'E'||'i'||'I'||'o'||'O'||'u'||'U')
You need to say if ( s[i] == 'a' || s[i] == 'A' || I'm sure you get the idea.

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.