-
compile problem
I have a problem compiling this program.Any suggestions is due tomorow.THANKS :confused:
Code:
#include <iostream.h>
#define MEAN = 65.4f
#define STD_DEV = 15.6f
int main(void)
{
float std_score;
int score;
char grade;
cout <<"Enter the score of a student or enter -1 to stop: \n";
cin >> score;
while (score != -1)
{
std_score = (score - MEAN) / STD_DEV;
if (std_score >= 1)
grade = ‘A’;
else if (std_score >= 0)
grade = ‘B’;
else if (std_score >= -1)
grade = ‘C’;
else if (std_score >= -2)
grade = ‘D’;
else
grade = ‘F’;
cout << "Grade = " << grade endl;
cout << " Enter the next score or enter -1 to stop ";
cin >> score;
}
return 0;
}
Cpp(17) : error C2059: syntax error : '='
Cpp(20) : error C2018: unknown character '0x91'
Cpp(20) : error C2018: unknown character '0x92'
Cpp(20) : error C2065: 'A' : undeclared identifierCpp(22) : error C2018: unknown character '0x91'
Cpp(22) : error C2018: unknown character '0x92'
Cpp(22) : error C2065: 'B' : undeclared identifier
Cpp(24) : error C2018: unknown character '0x91'
Cpp(24) : error C2018: unknown character '0x92'
Cpp(24) : error C2065: 'C' : undeclared identifier
Cpp(26) : error C2018: unknown character '0x91'
Cpp(26) : error C2018: unknown character '0x92'
Cpp(26) : error C2065: 'D' : undeclared identifier
Cpp(28) : error C2018: unknown character '0x91'
Cpp(28) : error C2018: unknown character '0x92'
Cpp(28) : error C2065: 'F' : undeclared identifier
Cpp(30) : error C2146: syntax error : missing ';' before identifier 'endl'
Cpp(30) : warning C4551: function call missing argument list
Error executing cl.exe.
.exe - 17 error(s), 1 warning(s)
-
Code:
#define MEAN = 65.4f
#define STD_DEV = 15.6f
should be
Code:
#define MEAN 65.4f
#define STD_DEV 15.6f
and I'm not sure what this is:
You seem to be using some weird character format.....Just use the normal apostraphe: '
Code:
cout << "Grade = " << grade endl;
You need one more << in there. I'll let you figure out where.
-
yes you right after "grade", thanks for the help.
Have a nice night
-
Just a quick thought: This is one of the reasons why programmers tend to prefer constants (in this case) to macros. (Not saying macros are 'evil' or what not, but there is something to be said for easier debugging ;))
Cheers
-
I'm still a newb, so I shouldn't nitpick..but...
#include <iostream.h>
should be
#include <iostream>
instead.
iostream.h is outdated.
-
No.. iostream.h is NOT outdated, at least not mine... it simply doesn't comply with the standard. Standard states iostream and use std namespaces.
-
No reason not to go with the standard.
-
Coding Standard Rule 17.1: Use Standard C++ Library headers defined by the language standard and not outdated .h headers. For example, use <iostream> and not <iostream.h>, <cstdio> and not <stdio.h>.
Side Note: ISO C++ defines the standard implemention of library components. Programmers should use these versions of the library rather than vendor-specific or C library versions.
The use of iostream.h is outdated and its presence is preserved for backward-compatibility. As of 1996, people use <iostream>, which just #includes iostream.h on many platforms, anyway. Using <iostream> will ensure that all the right definitions are defined, declarations are declared, includes are included, etc.
For further info, check out this link.
- Stack Overflow