I'm new to programming less than 4 days. I'm trying to create a Do While loop that asks the user for a letter, if that letter is lowercase it changes it to uppercase, and if its uppercase it changes to lowercase.
# include <iostream>
usingnamespace std;
int main()
{
int letter;
int c,C;
do
{
cout << "enter c or C (enter A to exit): ";
cin >> letter;
if ( letter = c )
{
cout << toupper(letter) << '\n';
}
if(letter = C)
{
cout << tolower(letter) << '\n';
}
if (letter != c,C)
{break;}
}
while (letter = c,C);
system("Pause");
return 0;
}
c is a variable or container, not a value. Also = is an assignment, not a comparison. Also, comma's are not OR operators.
I think you want this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
char letter;
do
{
cout << "enter c or C (enter A to exit): ";
cin >> letter;
if ( letter == 'c' || letter == 'C')
{
cout << toupper(letter) << '\n';
}
} while (letter == 'c' );
system("Pause");
return 0;
}