I have searched and tried so many combinations to implement ToUpper into my program but it simply doesn't work so I'm resorting to the message boards!
I'm coding in C# and I use Visual 6 C++ at Uni and Codeblocks at home and it works on neither.
Currently I'm using (repeatTest=='Y' || repeatTest=='y') but I want to implement <ctype.h> and ToUpper so that even if a lowercase y is entered it still accepts it.
I've tried
char repeatTest = repeatTest.ToUpper();
repeatTest = repeatTest.ToUpper();
both say 'ToUpper' in something not a structure or union
and many other combinations.
Here's my working code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
char repeatTest='Y';
while (repeatTest=='Y' || repeatTest=='y')
{
char answer=0, correctAnswer=0, questionNumber=1, testResult=0, NumberOfQuestions=1;
srand (time(0));
printf ("Test will begin, good luck\n\n\n\n");
for (NumberOfQuestions=0; NumberOfQuestions!=10; NumberOfQuestions++) {
int randomValue1=rand()%12+1;
int randomValue2=rand()%12+1;
printf("%i. What is %i x %i? ",questionNumber, randomValue1, randomValue2);
scanf("%i", &answer);
if (answer==(randomValue1*randomValue2)){
printf ("Correct\n\n");
++correctAnswer;
++questionNumber;
}
else {
printf ("Incorrect\n\n");
++questionNumber;
}
}
testResult = correctAnswer * 10;
printf ("You answered %i%% of the questions correctly\n\n",testResult);
"\n\n";
printf ("Would you like to have another go? Y or N\n\n");
scanf (" %c", &repeatTest);
if (repeatTest=='N' || repeatTest=='n'){
return 0;
}
system("cls");
}
system("pause");
}
Any responses would be appreacted