what am i doing wrong

im only trying to convert to upper case only if the user inputs them in lower case, if they are already upper case then i dont need to do anything...
we just learned about the islower, isupper, tolower, toupper today so im trying that instead of doing the -+32 thing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #include <iostream>

using namespace std;

int main()

{
    char key1, key2;
    cout << " Please enter characters. " << endl;
    cin >> key1 >> key2 ;

    {
        if (key1) && (key2) (islower);
            key1 && key2 = toupper;
    }

    cout << key1 << key2 << endl;

    return(0);
}
Lines 12 to 15 are complete gibberish, you should read up on how to use if statements and how to call functions.
it probably should look something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  #include <iostream>

using namespace std;

int main()

{
    char key1, key2;
    cout << " Please enter characters. " << endl;
    cin >> key1 >> key2 ;

     if (islower(key1) == true){key1 = toupper(key1);}
             
     if (islower(key2) == true){key2 = toupper(key2);}
     
     cout << key1 << key2 << endl;

     return(0);
}


I don't have a compiler to test it but I think that would work.
Eh, you don't need to check if something's lowercase before calling toupper on it -- you can just do
key1 = toupper(key1);
and it'll work regardless of whether key1 was previously lowercase, uppercase, or neither.
Thanks, I'll keep working on it. I appreciate the help I am struggling learning how to do all this.
Topic archived. No new replies allowed.