NO

Author Topic: Syntax Error 2001, etc  (Read 4750 times)

pman

  • Guest
Syntax Error 2001, etc
« on: March 11, 2013, 12:48:39 AM »
Need some help regarding the following below. Tried correcting but do not understand where the errors are exactly. Any help will be appreciated. Thank You


Code: [Select]
//=========================================================
//
// File: Grade Calc
//
//
//
//=========================================================


#include <stdio.h>
#include <stdbool.h>


//---------------------------------------------------------

int main(void)
{
  int  iValueEntered      = 0;
char cLetterGrade = 'F';
bool bValidGrade = true;
int status;

printf ("\n\n");
printf ("Decide what grade you should receive\n");
printf ("------------------------------------\n\n");

//-- A loop for entering numerical grades and find the letter grade.
//-- Loop ends when a "-1" is entered.
while (iValueEntered != -1)
{
bValidGrade = true;
printf ("Enter the grade you received:\n");
scanf  ("%d", iValueEntered);

if (("iValueEntered < 0") OR ("iValueEntered > 100"))
{
printf ("Numeric grade entered must be between 0 and 100.\n\n");
bValidGrade = false;
}

else if (iValueEntered == -1)
bValidGrade = false

else if (iValueEntered >= 90)
cLetterGrade = 'A';

else if (iValueEntered >= 80)
cLetterGrade = 'B';

else if (iValueEntered >= 70)
cLetterGrade = 'C';

else if (iValueEntered >= 65)
cLetterGrade = 'D';

else
cLetterGrade = 'F';

//-- print out the letter grade found.
if (bValidGrade)
printf ("The numeric grade of [%d] represents the Grade Letter <%c>.\n\n", iValueEntered, cLetterGrade);
}  // end of while loop.


printf ("--- Exiting program - Good Bye ---\n")

    return 0;
}
Building Grade Calc.obj.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(35): error #2001: Syntax error: expected ')' but found 'OR'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(35): warning #2130: Result of unsigned comparison is constant.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(35): warning #2027: Missing prototype for 'OR'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(35): error #2001: Syntax error: expected ';' but found ')'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(35): error #2061: Illegal statement termination.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(41): error #2157: Unrecognized statement.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(41): error #2001: Syntax error: expected ';' but found 'if'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(44): error #2001: Syntax error: expected ';' but found 'else'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(67): error #2001: Syntax error: expected ';' but found 'return'.
F:\ET156\Z_ET156_Winter2012_Quiz2\quiz2.c(21): warning #2114: Local 'status' is not referenced.
*** Error code: 1 ***
Done.
« Last Edit: March 11, 2013, 01:08:17 AM by Bitbeisser »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Syntax Error 2001, etc
« Reply #1 on: March 11, 2013, 01:23:00 AM »
Seriously?  :-\

Take a close look at the very first error (I actually get one previous one, on the scanf line) and the syntax coloring should give you an easy clue, specially when you compare it with the other if's following the first two.
Furthermore, on the same line, even with the inclusion of the stdbool.h header file, C doesn't know the word "OR" (or "or" for that matter) as an operand.
Beside that, you also need to check on properly terminating all your statements properly with a ";", this is C, not Pascal...  ;)

Ralf