What kind of language is that? "Not equal to more than something"? You must mean "not greater than", since a value can't equal a range of values. Somebody needs to grab a book on logic, or at least boolean algebra, quickly.
There are six relational operators:
(a==0) is the same as !(a!=0)
(a>0) is the same as !(a<=0)
(a<0) is the same as !(a>=0)
hahha.. i understand algebra... umm.. let me try to rephrase i have an array thats obtaining 20 values.. if it turns out that any more than five of those values are wrong than i want to post a message saying you got x amount wrong.. you failed or you got x amount wrong you passed.. so what im trying to do is at the end state how many i got wrong or right
#include <iostream>
using namespace std;
int main()
{
const int num_questions=20;
char userval[num_questions];
int count; // loop counter
int num1 = 65;
int num2 = 66;
int num3 = 67;
int num4 = 68;
cout<<"automated grader,, please enter in testees grades"<<endl;
cout<<"remember use caps only"<<endl;
cout<<endl;
for (count=0; count <num_questions; count++)
{
cout<< "enter the answer to question "<<(count + 1)<< " : ";
cin>> userval[count];
while (userval[count] != static_cast<char>(num4) && userval[count] != static_cast<char>(num3) && userval[count] != static_cast<char>(num2) && userval[count] != static_cast<char>(num1))
{
cout<<"please enter in a valid letter grade"<<endl;
cin>>userval[count];
}
}
cout<<endl;
cout<<endl;
if (userval[0]!= static_cast<char>(num2))
cout<<"you got the question 1 wrong correct answer is "<<static_cast<char>(num2)<<endl;
if (userval[1]!= static_cast<char>(num4))
cout<<"you got the question 2 wrong correct answer is "<<static_cast<char>(num4)<<endl;
if (userval[2]!= static_cast<char>(num1))
cout<<"you got the question 3 wrong correct answer is "<<static_cast<char>(num1)<<endl;
if (userval[3]!= static_cast<char>(num1))
cout<<"you got the question 4 wrong correct answer is "<<static_cast<char>(num1)<<endl;
if (userval[4]!= static_cast<char>(num3))
cout<<"you got the question 5 wrong correct answer is "<<static_cast<char>(num3)<<endl;
if (userval[5]!= static_cast<char>(num1))
cout<<"you got the question 6 wrong correct answer is "<<static_cast<char>(num1)<<endl;
if (userval[6]!= static_cast<char>(num2))
cout<<"you got the question 7 wrong correct answer is "<<static_cast<char>(num2)<<endl;
if (userval[7]!= static_cast<char>(num1))
cout<<"you got the question 8 wrong correct answer is "<<static_cast<char>(num1)<<endl;
if (userval[8]!= static_cast<char>(num3))
cout<<"you got the question 9 wrong correct answer is "<<static_cast<char>(num3)<<endl;
if (userval[9]!= static_cast<char>(num4))
cout<<"you got the question 10 wrong correct answer is "<<static_cast<char>(num4)<<endl;
if (userval[10]!= static_cast<char>(num2))
cout<<"you got the question 11 wrong correct answer is "<<static_cast<char>(num2)<<endl;
if (userval[11]!= static_cast<char>(num3))
cout<<"you got the question 12 wrong correct answer is "<<static_cast<char>(num3)<<endl;
if (userval[12]!= static_cast<char>(num4))
cout<<"you got the question 13wrong correct answer is "<<static_cast<char>(num4)<<endl;
if (userval[13]!= static_cast<char>(num1))
cout<<"you got the question 14 wrong correct answer is "<<static_cast<char>(num1)<<endl;
if (userval[14]!= static_cast<char>(num4))
cout<<"you got the question 15 wrong correct answer is "<<static_cast<char>(num4)<<endl;
if (userval[15]!= static_cast<char>(num3))
cout<<"you got the question 16 wrong correct answer is "<<static_cast<char>(num3)<<endl;
if (userval[16]!= static_cast<char>(num3))
cout<<"you got the question 17 wrong correct answer is "<<static_cast<char>(num3)<<endl;
if (userval[17]!= static_cast<char>(num2))
cout<<"you got the question 18 wrong correct answer is "<<static_cast<char>(num2)<<endl;
if (userval[18]!= static_cast<char>(num4))
cout<<"you got the question 19 wrong correct answer is "<<static_cast<char>(num4)<<endl;
if (userval[19]!= static_cast<char>(num1))
cout<<"you got the question 20 wrong correct answer is "<<static_cast<char>(num1)<<endl;
Dear God. What would you have done if there were two hundred values?
1. The while condition should be (replace 'var' with something suitable): while (var<'A' || var>'D').
2. For the love of god, get rid of all those ifs. Use a C string: char *answers="ABCDABCDABCD". Then use a loop to do the comparison:
1 2 3
for (short a=0;a<20;a++)
if (userval[a]!=answers[a])
cout <<"Answer "<<a+1<<" is wrong. The correct answer is "<<answers[a]<<endl;