Code: #include <iostream> using namespace std ; int main() { // Program code goes here. char letter; letter = ‘A’; //Declared then initialized int number; number = 100; float decimal = 7.5; double pi = 3.14159; bool isTrue = false; cout << “char letter:” << letter << endl ; cout << “int number:” << number << endl ; cout << “float decimal:” << decimal << endl ; cout << “double pi:” << pi << endl ; cout << “bool isTrue:” << isTrue << endl ; return 0 ; } please help!!
The only thing I can see wrong with this is the use of wrong quote marks: you're using ‘A’ instead of 'A', and “char letter:” instead of "char letter:" This would probably result in compiler errors.
vars.cpp:8:24: error: non-ASCII characters are not allowed outside of literals and identifiers char letter; letter = ‘A’; //Declared then initialized ^ vars.cpp:8:28: error: non-ASCII characters are not allowed outside of literals and identifiers char letter; letter = ‘A’; //Declared then initialized ^ vars.cpp:8:27: error: use of undeclared identifier 'A' char letter; letter = ‘A’; //Declared then initialized ^ vars.cpp:13:9: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “char letter:” << letter << endl ; ^ vars.cpp:13:17: error: expected '(' for function-style cast or type construction cout << “char letter:” << letter << endl ; ~~~~ ^ vars.cpp:13:24: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “char letter:” << letter << endl ; ^ vars.cpp:14:9: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “int number:” << number << endl ; ^ vars.cpp:14:16: error: expected '(' for function-style cast or type construction cout << “int number:” << number << endl ; ~~~ ^ vars.cpp:14:23: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “int number:” << number << endl ; ^ vars.cpp:15:9: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “float decimal:” << decimal << endl ; ^ vars.cpp:15:18: error: expected '(' for function-style cast or type construction cout << “float decimal:” << decimal << endl ; ~~~~~ ^ vars.cpp:15:26: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “float decimal:” << decimal << endl ; ^ vars.cpp:16:9: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “double pi:” << pi << endl ; ^ vars.cpp:16:19: error: expected '(' for function-style cast or type construction cout << “double pi:” << pi << endl ; ~~~~~~ ^ vars.cpp:16:22: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “double pi:” << pi << endl ; ^ vars.cpp:17:9: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “bool isTrue:” << isTrue << endl ; ^ vars.cpp:17:17: error: expected '(' for function-style cast or type construction cout << “bool isTrue:” << isTrue << endl ; ~~~~ ^ vars.cpp:17:24: error: non-ASCII characters are not allowed outside of literals and identifiers cout << “bool isTrue:” << isTrue << endl ; ^ 18 errors generated. those are the errors. i just want to execute it and see what it says. and xpi0t0s i dont understand what you mean,
Don't know how I can explain it in simpler terms. The compiler errors are exactly what I expected. You are using the wrong characters: for a char constant you surround the letter with single quote characters: one before, and one after. It's the same character twice. As in 'A'. What you're doing wrong is using quote characters that LOOK LIKE those but aren't. You are doing the same thing with string constants: instead of using "these" quotes, you are using quotes that look like 66 and 99, which is correct from a written English point of view, but this is C programming, not essay writing. Again it's the same character before and after the string and is on my keyboard on shift-2, if that's any help. If you still don't get it, then try getting someone near to you to read this update and see if they can understand it.