🔒 Closed Pa help naman po mga paps C++ po ito

Status
Not open for further replies.

ShantiDopeee

Forum Guru
Pahelp po, di ko na po alam ano problema submission na namin bukas eh, ito po yung code


#include <iostream>
using namespace std;

int main()
{

char x;
int vowel,consonant;
{
cout << "Enter a character: ";
cin >> x;
}
vowel = ((x=='a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'A' || x == 'E' || x == 'I' || x == 'O' || x== 'U'));

consonant = ( x=='b' || x=='c' || x=='d' || x=='f' || x=='g' || x=='h' || x=='j' || x=='k' || x=='l' || x=='m' || x=='n' || x=='p' || x='q' || x=='r' || x=='s' || x=='t' || x=='v' || x=='w' || x=='x' || x=='y' || x=='z' || x=='B' || x=='C' ||x=='D' || x=='F' || x=='G' || x=='H' || x=='J' || x=='K' || x=='L' || x=='M' || x=='N' || x=='P' || x=='Q' || x=='R' || x=='S' ||x=='T' ||x=='V' ||x=='W' || x=='X' ||x=='Y' || x== 'Z') ;

if (x = vowel) {
cout << "Is "<<x<< " a valid alphabet?: YES. " ;
cout << "Is "<<x<< " a VOWEL or CONSONANT?: VOWEL.";
} else if (x = consonant) {
cout << "Is "<<x<< " a valid alphabet?: YES. " ;
cout << "Is "<<x<< " a VOWEL or CONSONANT?: CONSONANT.";
} else {
cout << " "<<x<< " is not a valid alphabet.";
}

return 0;

}

error : lvalue daw po bandang x=='Z' di ko sya mafix eh sana may makatulong
 
[CODE lang="cpp" title="Answer"]#include <iostream>
using namespace std;

int main()
{

char x;
int vowel,consonant;
{
cout << "Enter a character: ";
cin >> x;
}
vowel = (x =='a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'A' || x == 'E' || x == 'I' || x == 'O' || x== 'U');

consonant = ( x == 'b' || x == 'c' || x == 'd' || x == 'f' || x == 'g' || x == 'h' || x == 'j' || x == 'k' || x == 'l' || x == 'm' || x == 'n' || x == 'p' || x == 'q' || x == 'r' || x == 's' || x == 't' || x == 'v' || x == 'w' || x == 'x' || x == 'y' || x == 'z' || x=='B' || x=='C' ||x=='D' || x=='F' || x=='G' || x=='H' || x=='J' || x=='K' || x=='L' || x=='M' || x=='N' || x=='P' || x=='Q' || x=='R' || x=='S' ||x=='T' ||x=='V' ||x=='W' || x=='X' ||x=='Y' || x== 'Z');

if (x = vowel) {
cout << "Is "<<x<< " a valid alphabet?: YES. " ;
cout << "Is "<<x<< " a VOWEL or CONSONANT?: VOWEL.";
} else if (x = consonant) {
cout << "Is "<<x<< " a valid alphabet?: YES. " ;
cout << "Is "<<x<< " a VOWEL or CONSONANT?: CONSONANT.";
} else {
cout << " "<<x<< " is not a valid alphabet.";
}

return 0;

}[/CODE]
 
Makiki try nalang po ts.
C++:
#include <iostream>
using namespace std;
    bool isVowel(char c){
        switch(toupper(c)){
            case 'A': case 'E': case 'I': case 'O': case 'U':
                return  true; }
    return false; }
int main() {
    char input;
    cout<<"Input:";
    cin>>input;
    cout<<"is '" <<input<<"' a valid alphabet? "<<(isdigit(input)? "False" : "True")<<endl;
    if(!isdigit(input))
            cout<<"Then '"<<input<<"' is a "<<(isVowel(input)? "Vowel" : "Consonant")<<endl;
}
1616657721884.png
1616657742836.png
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 3
    Replies
  • 368
    Views
  • 2
    Participants
Last reply from:
Arcturus

Trending Topics

Online now

Members online
1,024
Guests online
1,216
Total visitors
2,240

Forum statistics

Threads
2,274,059
Posts
28,953,407
Members
1,235,039
Latest member
Drifter007
Back
Top