English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

do
{
cout << "Please enter your grades.\n";
cout << "Period " << i << ":\n";
cin >> grade;
if(toupper(grade)== )
i++;
}while(i>0 && i<9);

im trying to make the "toupper" work so that all the "grade" entries are in capital letters. how do you do that?

2007-04-05 09:38:38 · 4 answers · asked by Kaitlyn 2 in Computers & Internet Programming & Design

4 answers

assuming "grade" is char , here's how you do it:


char toupper (char letter)
{
if (letter >= 'a' && letter <= 'z')
{
letter = letter - 'a' + 'A';
}
return letter;
}

2007-04-05 09:58:05 · answer #1 · answered by iluxa 5 · 1 0

if(toupper(grade)== )

first the code you typed in is missing the test argument on the right side of the ==

Simplify your steps and don't try to do to much in one line. If you can seperate steps its easier to see what you are trying to do.

Use seperate variables for user input and toUpper conversion.

cin>> userInput;
grade = toupper(userInput);

doing so will make the if statement easier to read and see exactly what you are trying to do.

if (grade == 'A')
{
'your code goes here
}

another way around this problem is to test for either 'a' OR 'A' and not do a toupper conversion

2007-04-05 21:28:46 · answer #2 · answered by MarkG 7 · 0 0

What language exactly? that kinda of looks like c++

2007-04-05 16:43:13 · answer #3 · answered by Anonymous · 0 1

gd code here


call however you want

2007-04-05 16:59:14 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers