This is due in 50 minutes, so hopefully this gets a quick response. I'm getting an error that the internet isn't giving a clear response for.
First and foremost (even if I get my program working), for posterity sake will someone please explain what the error "NON-LVALUE IN ASSIGNMENT" actually means?
OK, now that being said my instructor has asked the class to take our program to determine prime numbers and modify it by including a function. For the prime number test. It worked fine before, so I'm not really interested in modifying the logic to "make more sense" (as I see this type of suggestion a lot on here) I'm sure there are a billion different ways to do this. I just need to know what is broke and why, if I can understand the error I can fix the error.
===> I'm getting the aforementioned error on line 50 (I bolded it). Here's what I got so far:
while (num1 != 0)
{
// Test for number being greater than 2
while (num1 <= 2)
{
cout << setfill ('X') << setw(76) << "X" << endl;
cout << setfill ('X') << setw(38) << " ERROR " << setfill ('X') << setw(38) << "X" << endl;
cout << " | " << setw(4) << setfill( ' ' ) << num1 << " is not greater than 2. Please re-enter an integer greater than 2. |" << endl;
cout << setfill ('X') << setw(76) << "X" << endl << endl << endl;
cout << "Enter an integer greater than 2 for the lower end of the range (ENTER 0 TO QUIT): ";
cin >> num1;
cout << endl << endl;
}
// Input Upper Range Number
cout << "Enter an integer greater than " << num1 << " for the upper end of the range: ";
cin >> num2;
cout << endl << endl;
// Test for number being greater than low end number
while (num2 <= num1)
{
cout << setfill ('X') << setw(76) << "X" << endl;
cout << setfill ('X') << setw(38) << " ERROR " << setfill ('X') << setw(38) << "X" << endl;
cout << " | " << setw(4) << setfill( ' ' ) << num2 << " is not greater than " << num1 <<". |" << endl;
cout << setfill ('X') << setw(76) << "X" << endl << endl << endl;
cout << "Enter an integer greater than " << num1 << " for the upper end of the range: ";
cin >> num2;
cout << endl << endl;
}
cout << "The Prime Numbers between " << num1 << " and " << num2 << " are:";
// Call to Function: primetest
primetest (num1, num2, notprime);
// Final Output
if (!notprime)
{
cout << "[There are no prime numbers in that range.]" << endl << endl << endl; // [PRIME RESPONSE]
}
// Quit?
cout << "Enter an integer greater than 2 for the lower end of the range (ENTER 0 TO QUIT): ";
cin >> num1;
}
cake ();
system("pause");
return 0;
}
... but apparently I suck at the math worse than I thought as the expected results of 10 for the lower range and 20 for the upper are 11 13 17 19, and I'm getting ... 10 ... *sigh*
OK well lets see what kind of bad math I implemented here.
Thanks for the info ... so if I see that error in the future it means I'm trying to assign a value to something that can't take that assignment?
lvalue is ... "literal value" or something like that?
An L-Value (Left-Value) is an operand* that can appear on both the left-hand & right-hand side of an assignment. L-Values generally have an address in memory, so the compiler knows where to store the value on the right-hand side.
An R-Value is also an operand that generally doesn't have an address in memory. These are usually magic constants or other objects, such as L-Values.
* An operand is a piece of data within an expression, such as an object, or magic constant (literal).