// JavaScript Document

var currQuiz = 1;
var currQuestion = 1;
var score = 0;

/********************** Answers ****************************************/

var correctAnswer = new Array(
	
         3, 2, 2, 1, 4, 2, 3, 2, 1, 2, 1, 4, 3, 3, 2,	// Quiz 1

	 2, 2, 4, 4, 4, 2, 4, 2, 1, 2, 3, 4, 2, 2, 3,	// Quiz 2

	 3, 3, 2, 4, 2, 2, 3, 4, 4, 3, 3, 1, 1, 4, 3,	// Quiz 3

	 3, 4, 1, 2, 3, 2, 3, 4, 2, 1, 3, 3, 1, 2, 3,	// Quiz 4

	 3, 1, 2, 2, 2, 3, 2, 1, 4, 2, 4, 2, 2, 2, 3,	// Quiz 5

	 4, 2, 3, 2, 3, 4, 2, 4, 1, 2, 1, 2, 1, 3, 3,	// Quiz 6

	 1, 1, 2, 2, 3, 3, 4, 3, 2, 4, 3, 3, 4, 1, 3,	// Quiz 7

	 2, 4, 1, 2, 2, 3, 1, 1, 4, 4, 2, 4, 1, 1, 1,	// Quiz 8

	 3, 4, 4, 3, 1, 2, 3, 3, 2, 2, 3, 2, 3, 1, 3,	// Quiz 9

	 2, 3, 3, 2, 1, 3, 3, 2, 4, 4, 2, 3, 2, 1, 2	// Quiz 10
);

/********************** Quizzes ****************************************/

/*** Quiz1 ***/
var quiz1 = 
[
[
// question 1 (answer 3)
	"Which list of type specifiers designates more than one type?",

	"short,  signed short,  short int,  signed short int",
	"long,  signed long,  long int,  signed long int",
	"unsigned,  unsigned  long,  unsigned long int",
	"unsigned short,  unsigned short int"
],

[
// question 2 (answer 2)
"What three properties does a storage class specifier determine when used " +
"in a variable declaration? \r\n\r\n" + 
"For example:   extern int x; ",

"scope,  linkage,  type",
"storage duration,  scope,  linkage",
"type,  storage duration,  scope",
"constness,  linkage,  scope"
],

[
// question 3 (answer 2) 
"What three properties does a storage class specifier determine when used " +
"in a variable declaration? \r\n\r\n" +
"For example:   extern int x; ",

"scope,  linkage,  type",
"storage duration,  scope,  linkage",
"type,  storage duration,  scope",
"constness,  linkage,  scope"
],

[
// question 4 (answer 1)
"What is the type specifier?\r\n\r\n" +
	"int *x;",

"int",
"int *",
"*",
"*x"
],

[
// question 5 (answer 4)
"What is the declarator?\r\n\r\n" +
	"int *x;",

"int",
"int *",
"*",
"*x"
],

[
// question 6 (answer 2)
"What is the type of x?\r\n\r\n" +
	"int *x ;",

"int",
"int *",
"*",
"*x"
],

[
// question 7 (answer 3) - ref - std
"What is the type of  \" hello \" ?\r\n\r\n" +
	"printf ( \" hello \" ) ;",

"char",
"char *",
"char[ ]",
"long"
], 

[
// question 8 (answer 2)
"What is the keyword  \" static \" ?",

"type specifier",
"storage class specifier",
"type qualifier",
"declarator"
],

[
// question 9 (answer 1)
"What is the keyword \" long \" ?",

"type specifier",
"storage class specifier",
"type qualifier",
"declarator"
],

[
// question 10 (answer 2)
"What is the type of f?\r\n\r\n" +
    "char (*f)(void);",

"function returning a pointer to a char",
"pointer to a function returning char",
"function returning char",
"pointer to a char"
],

[
// question 11 (answer 1)
"What is the identifier in this declaration?\r\n\r\n" +
    "char (*f)(void);",

"f",
"*f",
"(*f)",
"(*f)(void)",
],

[
// question 12 (answer 4)
"What is the declarator in this declaration?\r\n\r\n" +
    "char * f(int, int);",

"* f",
"char * f",
"f(int, int)",
"* f(int, int)",
],

[
// question 13 (answer 3)
"What is the type of x?\r\n\r\n" +
	"int *(*x[5])(void);",

"array of pointers to int",
"function returning a pointer to an array of int",
"array of pointers to functions returning pointer to an int",
"array of functions with returning pointer to a pointer to an int",
],

[
// question 14 (answer 3)
"What x is in the same namespace as the x in the following declaration? \r\n" +
	"(assume all declarations are in main, including int x; )\r\n\r\n" +
	"int x; ",

"struct x {\r\n" +
	"              int y;\r\n" +
	"};",
"struct y {\r\n" +
	"              int x;\r\n" +
	"};",
"enum a{ x, y, z};",
"enum x{ RED, GREEN, BLUE };",
],

[
// question 15 (answer 2)
"What is the value of b?     int a = 2;\r\n" +
"                                         {    \r\n" +
"                                              int a = 10;\r\n" +
"                                              int b = a;  \r\n" +
"                                         }", 

"2",
"10",
"implementation defined",
"undefined"
]

];


// Quiz 2 ****************** Lexical Elements *************************

var quiz2 = 
[
[
// question 1 (answer 2)
"What is the minimum number of character sets required by Standard C?",

"1",
"2",
"3",
"4"
],

[
// question 2 (answer 2)
"Which is considered a logical source line?",

"a string of characters included in double quotes",
"a line ending in a backslash followed by an end-of-line marker",
"a line ending with a comma",
"a line ending with a semicolon"
],

[
// question 3 (answer 4)
"What is a trigraph?",

"type of bitmap",
"two-type characters used to represent unicode",
"multibyte character used to represent international character sets",
"sequence of characters used to represent some " +
	 " punctuation characters"
],

[
// question 4 (answer 4)
"What are the 6 tokens defined in Standard C?",

"keyword,  identifier,  constant,  function,  operator,  punctuator",
"keyword,  identifier,  constant,  end-of-line marker,  operator,  punctuator",
"keyword,  identifier,  constant,  line,  operator,  punctuator",
// why does it include the second whitespace for punctuator and not others above
// must use only one whitespace before punctuator for word wrap
"keyword,  identifier,  constant,  string-literal,  operator, punctuator"
],

[
// question 5 (answer 4)
"What is the radix of an integer beginning with 0x ?",

"binary",
"octal",
"decimal",
"hexadecimal"
],

[
// question 6 (answer 2)
"How is the string literal \"\\n\" stored?",

"one character      \\n",
"two characters     \\n     \\0",
"three characters   \\      n     \\0",
"five characters     \"      \\        n        \\      \""
],

[
// question 7 (answer 4)
"How many characters does the escape sequence \\t advance?",

"4",
"6",
"8",
"dependent on the operating system"
],

[
// question 8 (answer 2)
"What is NOT a definition of main specifically defined in the standard? \r\n\r\n",

	"int main(void) \r\n" +
		"{ \r\n " +
		"   /* ... */ \r\n" +
		"}",
	"int main(int argc,  char argv) \r\n" +
		"{ \r\n " +
		"   /* ... */ \r\n" +
		"}",
	"int main(int argc,  char *argv[ ]) \r\n" +
		"{ \r\n " +
		"   /* ... */ \r\n" +
		"}",
	"int main(int argc,  char **argv) \r\n" +
		"{ \r\n " +
		"   /* ... */ \r\n" +
		"}"
],

[

// question 9 (answer 1)
"What escape sequence does not represent white-space?",

"\\a",
"\\n",
"\\r",
"\\t"
],

[
// question 10 (answer 2)
"Which list includes escape sequences defined in Standard C? \r\n",

"\\a  \\b  \\f  \\n  \\r  \\w  \\v",
"\\a  \\b  \\f  \\n  \\r  \\t  \\v",
"\\a  \\b  \\m  \\n  \\r  \\t  \\v",
"\\a  \\b  \\f  \\n  \\p  \\t  \\v"
],

[
// question 11 (answer 3)
"What is NOT equal to zero?",

"'\\0'",
"NULL",
"\"0\"",
"0x0"
],

[
// question 12 (answer 4)
"Which is NOT a valid identifier?",

"abc",
"_abc",
"a1b",
"1ab"
],

[
// question 13 (answer 2)
"How many bytes is a wchar_t ?",

"1",
"2",
"4",
"8"
],

[
// question 14 (answer 2)
"What is the name of the original ANSI C Standard?",

"American National Standard X3J11",
"American National Standard X3.159-1989",
"IS0/IEC 9899:1990",
"IS0/IEC 9899:1999"
],

[
// question 15 (answer 3)
"What is the name of the international standard for C that ANSI has approved?",

"American National Standard X3.159-1989",
"ISO/IEC JTC1/SC22/WG14",
"IS0/IEC 9899:1990",
"IS0/IEC 9899:1999"
]
];

// Quiz 3 ****************** Types ************************************

var quiz3 = 
[
[
// question 1 (answer 3)
"Which declares a variable of a scalar type?",

"int arr[5];",
"struct sTag { \r\n" +
	"    int x; \r\n" +
	"} s1;",
"int *p;",
"extern char a[ ];",
],

[
// question 2 (answer 3)
"Which declares a variable of an aggregate type?",

"void (*f)(void);",
"void f(void);",
"extern char a[ ];",
"int *p;",
],

[
// question 3 (answer 2)
"What is the value of \" hello \" ?\r\n\r\n" +
	"printf ( \" hello \" ) ;",

"104 - the ASCII integer value of 'h'",
"a pointer to the first element of a static array of characters",
"5 - the length of the string",
"5 - the length of the string including the null character",
],

[
// question 4 (answer 4)
"How is this string literal stored?\r\n\r\n" +
	"char *pstr = \"hello\" ;",

"in an array of 6 elements of type char set aside temporarily that is destroyed at the " +
	"next sequence point",
"in an array of 6 elements of type int set aside temporarily that is destroyed at the " +
	"next sequence point ",
"in a statically allocated array of 6 elements of type int set aside at load-time",
"in a statically allocated array of 6 elements of type char set aside at load-time",
],

[
// question 5 (answer 2)
"How does the compiler rewrite arr[10] below? \r\n\r\n" +
	"int arr[10]; \r\n\r\n" +
	"arr[2] = 5;",

"*arr + 2",
"*(arr + 2)",
"arr + 1",
"arr + 2",

],

[
// question 6 (answer 2)
"What is the value of 3[arr] using the declaration:\r\n\r\n" +
	"int arr[5] = { 1, 2, 3, 4, 5 };",

"3",
"4",
"7",
"illegal syntax",

],

[
// question 7 (answer 3)
"Which is NOT equal to the value of: &a[0] \r\n\r\n" +
    "int a[3] = { 1, 2, 4 };",

"a",
"&a",
"*a",
"&*a",
],

[
// question 8 (answer 4)
"What is the type of p?\r\n\r\n" +
    "int * const p; ?",
"const int",
"pointer to an int",
"pointer to a const int",
"const pointer to an int",
],

[
// question 9 (answer 4)
"Which does NOT declare an incomplete type or declare a variable with an " +
	"incomplete type?  (assuming no other definitions or declarations " +
	"in the file) \r\n\r\n",

"extern arr[ ];",
"extern const arr[ ];",
"struct sTag;",
"enum color { RED, GREEN, BLUE };",
],

[
// question 10 (answer 3)
"What is the type specifier? \r\n" +
	"      struct { \r\n" +
	"              int x, y; \r\n" +
	"              char a, b; \r\n" +
	"            } s1;",

"s1",
"struct",
"struct { \r\n" +
	"     int x, y; \r\n" +
	"     char a, b; \r\n" +
	"}",

"struct { \r\n" +
	"     int x, y; \r\n" +
	"     char a, b; \r\n" +
	"} s1",
],

[
// question 11 (answer 3)     
"Which reserves storage for an identifier (object definition)? \r\n\r\n" +
	"(all can have file or block scope)",

"extern char arr[ ];",
"void f(void);",
"int (*f)(void);",
"enum color { RED, BLUE, GREEN };",
],

[
// question 12 (answer 1)
"Which reserves storage for an identifier (object definition)? \r\n\r\n" +
	"(assume all have file scope)",

"extern int x = 4;",
"struct s { \r\n" +
	"     int x; \r\n" +
	"     char a; \r\n" +
    "};",
"void f(void);",
"enum color { RED, BLUE, GREEN };",
],

[
// question 13 (answer 1)
"How do you indicate that the minimum size for a constant is to be the width " +
"of type \" long \" ?",

"L suffix",
"L prefix ",
"(L) prefix",
"(L) suffix",
],

[
// question 14 (answer 4)
"What size is an \" int \" ?",
"32 bits",
"16 bits",
"8  bits",
"dependent on the machine's \"word\" size",
],

[
// question 15 (answer 3)
"Which is NOT a valid declaration according to Standard C?",

"signed x;",
"long double x;",
"long float x;",
"unsigned long int x;"
]
];

// Quiz 4 ****************** Expressions ******************************

var quiz4 = 
[
[
// question 1 (answer 3)
"What is a sequence point?",

"the end of a preprocessor line which indicates that any macro expansion is " +
	"to have been done",
"the end of each of the 8 translation phases that is described by the standard " +
	"that includes preprocessing, compilation, and linking",
"a point in a program's execution where all previous side-effects are to have " +
	"happened and where no subsequent side effects have occurred",
"the end of a conditional statement",
], 
 
[ 
// question 2 (answer 4)
"What operator is NOT short-circuiting?",

"&&",
"||",
"? :",
"<=",
], 
 
[ 
// question 3  (answer 1) - c99 d.2.3 - standard
"After the if statement, what is y ?\r\n\r\n" +
	"int x = 0,  y = 0;\r\n" +
	"if( x == 0  ||  ++y ) \r\n" +
	"             ;",

"0",
"1",
"2",
"undefined",
], 
 
[ 
// question 4 (answer 2) 
"After the if statement, what is y ?\r\n\r\n" +
	"int x = 1,  y = 0;\r\n" +
	"if( x == 1  &&  ++y ) \r\n" +
	"             ;",

"0",
"1",
"2",
"undefined",
], 
 
[ 
// question 5 (answer 3)
"What is an object (not a C++ object)?",

"the object file that the linker produces",
"a function",
"a region in memory that can be store values",
"an aggregate type",

], 
 
[ 
// question 6 (answer 2)
"Choose the lvalue? \r\n\r\n" +
	"int * f(void); \r\n" +
	"enum { RED, GREEN, BLUE } color;\r\n" +
	"struct s1 { int x; };",

"f",
"color",
"s1",
"5L",
], 
 
[ 
// question 7 (answer 3)
"Which expression is NOT a \" modifiable \" lvalue? \r\n\r\n" +
	"int x;\r\n" +
	"int arr[5];\r\n" +
	"const int *p;",

"x",
"arr[2]",
"arr",
"p",
], 
 
[ 
// question 8 (answer 4)
"Choose the expression that IS a \"modifiable\" lvalue? \r\n" +
	"     int arr[5]; \r\n" +
	"     enum color { RED, GREEN, BLUE } ;\r\n" +
	"     struct s1 { int x; }; \r\n" +
	"     const int *p;",

"arr",
"color",
"s1",
"p",
], 
 
[ 
// question 9 (answer 2)
"Which is an rvalue?",

"int",
"0x4",
"sizeof",
"typedef",
], 
 
[ 
// question 10 (answer 1)
"What is printed?\r\n" +
	"    char arr[ ] = \"true\" ; \r\n" +
	"    char *p = arr; \r\n" +
	"    for( ; *p ; p += 2 ) \r\n" +
	"          printf( \"%c\", *p);",

"tu",
"ru",
"rue",
"ue",
], 
 
[ 
// question 11  (answer 3) - modern chapter 4
"Which does not include an expression? \r\n\r\n" +
	"int x;",

"5;",
"x;",
";",
"-x;",
], 
 
[ 
// question 12 (answer 3)
"What is printed? (this contains a common typing error)\r\n" +
	"     int x = 2; \r\n" +
	"     if( x = 5 )  x-- ; \r\n" +
	"     else       x++ ; \r\n" +
	"     printf( \"%d\", x );",

"1",
"3",
"4",
"6",
], 
 
[ 
// question 13  (answer 1) - p. 247 Ref and 6.3.2.1  - p. 39 standard
"What is the type of the value of x after its evaluation and before being added to 5?\r\n" +
	"     const int x; \r\n" +
	"     int y; \r\n" +
	"     y = x + 5;",

"int",
"const int ",
"float",
"double",
], 
 
[ 
// question 14  (answer 2) - p. 95 modern p. 249 ref
"What is printed: \r\n\r\n" +
	"int a = 1; \r\n" +
	"printf(\"%d\", ++a, a + 5); ",

"1",
"2",
"7",
"undefined",
], 
 
[ 
// question 15 (answer 3) 
"What is printed: \r\n\r\n" +
	"int a = 1; \r\n" +
	"printf(\"%d\", (++a, a + 5)); ",

"2",
"6",
"7",
"undefined",
]
]

// Quiz 5 ****************** Statements *******************************
var quiz5 = 
[
[
// question 1  (answer 3) p.261 ref can be not evaluated
"Which statement doesn't have a side effect? \r\n\r\n" +
	"int x = 5;",

"x++;",
"x = 10;",
"x + 5;",
"x--;",
], 
 
[ 
// question 2 (answer 1) - p. 260 Ref "any expression can be made a statement... add ;"
"Which is NOT a statement? \r\n\r\n",

"int x;",
";",
"4;",
"0xF;",
], 
 
[ 
// question 3 -  (answer 2) printf is the body
"What is printed? \r\n\r\n" +
	"int x = 3; \r\n" +
	"for( ; x--; ) \r\n" +
	"        printf( \"%d\", x );",
   
"3210",
"210",
"21",
"compile-time error",
], 
 
[ 
// question 4 (answer 2) - p. 13 modern
"Which is not a statement? \r\n\r\n" +
	"int x; \r\n" +
	"struct s { int x; }; \r\n" +
	"enum { RED, BLUE, GREEN } color;",

"x;",
"struct s s1;",
"color;",
"4;",
], 
 
[ 
// question 5 (answer 2)
"Choose the equivalent statement? \r\n\r\n" +
	"a = b ? c : d;",

"if(a = b)\r\n" +
	"    a = c; \r\n" +
	"else \r\n" +
	"    a = d;",
"if(b != 0) \r\n" +
	"    a = c; \r\n" +
	"else \r\n" +
	"    a = d;",
"if( !b ) \r\n" +
	"    a = c; \r\n" +
	"else \r\n" +
	"    a = d;",
"if(b != 0) \r\n" +
	"    a = d; \r\n" +
	"else \r\n" +
	"    a = c;",
], 
 
[ 
// question 6 (answer 3)
"Which statement is NOT a jump statement?",

"break;",
"goto lb;",
"case lb;",
"continue;",
], 
 
[ 
// question 7 (answer 2)
"What kind of statement is this: \r\n\r\n" +
	"for(i = 0; i < 10; i++) \r\n" +
	"          ;",

"selection statement",
"iterative statement",
"compound statement",
"jump statement",
], 
 
[ 
// question 8 (answer 1)
"What kind of statement is this: \r\n\r\n" +
	"switch(x) { \r\n" +
	"case 1: y = 4; break; \r\n" +
	"case 2: y = 7; break; }",

"selection statement",
"iterative statement",
"compound statement",
"labeled statement",
], 
 
[ 
// question 9 (answer 4)
"What kind of statement is this? \r\n\r\n" +
	"return;",

"selection statement",
"iterative statement",
"labeled statement",
"jump statement",
], 
 
[ 
// question 10 (answer 2)
"What is  count  after exiting this loop? \r\n" +
	"for(i = 0, count = 0;  i < 3;  i++) \r\n" +
	"{	if( !i )	continue; \r\n" +
	"	count++;   \r\n" +  
	"} ",

"1",
"2",
"3",
"4",
], 
 
[ 
// question 11  (answer 4)
"What is count after exiting the outer for loop? \r\n\r\n" +
	"for(i = 0, count = 0; i < 10; i++) \r\n" +
	"       for(j = 0; j < 5; j++, count++)\r\n" +
	"                    ;",

"10",
"15",
"36",
"50",
], 
 
[ 
// question 12 (answer 2)
"What is count after exiting the outer for loop? \r\n" +
	"     int i = 0, count = 0; \r\n" +
	"     do { \r\n" +
	"     i++; count++; \r\n" +
	"     } while (i < 10);",

"9",
"10",
"11",
"100",
], 
 
[ 
// question 13 (answer 2)
"Which is illegal? \r\n",

"((( 5 )));   ",
"(((( ))));   ",
"{{{ 5; }}};  ",
"{{{{ }}}};   ",
], 
 
[ 
// question 14 (answer 2)
"Which is illegal? \r\n",


"5,5,5,5,5;  ",
"{{{ 5 }}};   ",
"{{{(5);}}};  ",
"((( 5 )));   ",
], 
 
[ 
// question 15 (answer 3) - 3 prefix increment
"Which is illegal? \r\n\r\n" +
"int x = 4;",

"-+-x",
"-  +x",
"++-x",
"-  -x",
]
];


// Quiz 6 ****************** Functions ********************************
var quiz6 = 
[
[
// question 1 (answer 4)
"What is an activation record?",

"a table that contains a list of all functions in an application",
"a table that contains addresses of all the statically allocated data for an application ",
"the table that is passed to the linker from the compiler that contains external " +
	"references",
"a data structure containing the variables belonging to one particular " +
	"invocation of a function",
], 
 
[ 
// question 2 (answer 2)
"When a prototype is not used, what is the implicit declaration the compiler " +
	"uses?\r\n\r\n" +
	"sqrt(9);",
"static int sqrt( );",
"extern int sqrt( );",
"extern double sqrt( );",
"extern long sqrt( );",
], 
 
[ 
// question 3 (answer 3)
"What happens when arguments appear in a function call that IS " +
    "bound to a prototype and the actual arguments differ in type " +
    "from the formal parameters?",

"all arguments are passed as is",
"float arguments are converted to double and\r\n" +
    "integral promotions are performed(char and shorts are promoted to int)",
"each argument is implicitly converted to the type of the corresponding " +
    "parameter as if by assignment",
"each argument is implicitly converted to the \"widest\" type of the corresponding " +
    "parameter list",
], 
 
[ 
// question 4 (answer 2)
"What happens when arguments appear in a function call that IS NOT " +
    "bound to a prototype ?",

"all arguments are passed as is",
"float arguments are converted to double and\r\n" +
    "char and short arguments are promoted to int",
"float arguments are converted to double and\r\n" +
    "char and short arguments are promoted to long)",
"float arguments are converted to double and\r\n" +
    "char and short arguments are promoted float )",
], 
 
[ 
// question 5 (answer 3)
"What is the type of f?\r\n\r\n" +
    "char * f(int, int);",

"pointer to a function",
"pointer to a character",
"function returning a pointer to a char",
"pointer to a function returning a char",
], 
 
[ 
// question 6 (answer 4)
"What is the type of f?\r\n\r\n" +
    "void (*f)(void);",
"void",
"pointer to void",
"function returning a pointer to a void",
"pointer to a function returning void",
], 
 
[ 
// question 7 (answer 2)
"What is printed with    f(arr)    called from main when an int is 4 bytes: \r\n" +
	"     int arr[10];\r\n\r\n" +
	"     void f(int *arr) \r\n" +
	"     {    printf(\"%u\", sizeof( arr ));    } ",

"1",
"4",
"40",
"41",
], 
 
[ 
// question 8  (answer 4) - p. 167 ref
"What is the result of sizeof(f) with an int of 4 bytes? \r\n\r\n" +
	"int f(int x)  \r\n" +
	"{     int y; \r\n" +
	"}",

"1",
"4",
"8",
"error",
], 
 
[ 
// question 9 (answer 1)
"How many copies of the code in f (not the variables in f) are loaded into memory in this program? \r\n" +
	"void f(int); void f2(void (*f)(int));\r\n" +
	"main( ) \r\n" +
	"{    f(5); f(2); f2(f)  }",

"1",
"2",
"3",
"4",
], 
 
[ 
// question 10 (answer 2)
"What linkage does f have? \r\n" +
	"     static void f(void); \r\n" +
	"     main( ) \r\n" +
	"     {\r\n" +
	"        /* ... */ }",

"external linkage",
"internal linkage",
"no linkage",
"register linkage",
], 
 
[ 
// question 11 (answer 1)
"What linkage does f have? \r\n" +
	"     void f(void); \r\n" +
	"     main( ) \r\n" +
	"          {\r\n" + 
	"             /* ... */ }",

"external linkage",
"internal linkage",
"no linkage",
"register linkage",
], 
 
[ 
// question 12 (answer 2)
"What is one thing determined by a calling convention?",

"the order in which the arguments of a function call are evaluated",
"the order in which the arguments of a function call are pushed onto the stack",
"the storage duration of variables in a function",
"the scope of variables in a function",
], 
 
[ 
// question 13 (answer 1)
"What is the return value of f(5)? \r\n  " +
	"int f(int x) \r\n" +
	"{	if (x == 1) return 1; \r\n" +
	"	else  return 1 + f(x - 1); " +
	"}",

"5",
"6",
"7",
"25",
/*
f(5) finds that x is not equal to 1, so calls 
	f(4) finds that x is not equal to 1, so calls 
		f(3) finds that x is not equal to 1 so calls
			f(2) finds that x is not equal to 1 so calls
				f(1) finds that x IS equal to 1 so returns 1 causing
			f(2) to return 1 + 1 = 2, causing 
		f(3) to return 1 + 2 = 3, causing
	f(4) to return 1 + 3 = 4, causing 
f(5) to return 1 + 4 = 5
*/
], 
 
[ 
// question 14 (answer 3)
"Which is an invalid use of void?",

"void f(int);",
"void f(void);",
"void x;",
"void *x;",
], 
 
[ 
// question 15 (answer 3)
"Which is a declaration allowing any pointer type to be passed as an argument?",

"void f(int *);",
"void f(void);",
"void f(void *);",
"void f(cast *);",
]
];

// Quiz 7 ****************** Conversions and Representations **********

var quiz7 = 
[
[
// question 1 (answer 1)
"What type does a floating constant evaluate to without any suffixes?",
"double",
"float",
"long double",
"long",
], 
 
[ 
// question 2 (answer 1)
"What is the value of y after assignment?\r\n" +
	"   int x = 353;   (in binary  1  0110 0001) \r\n" +
	"   int y; \r\n" +
	"   char *p = (char *)&x;\r\n" +
	"   y = *p;",

"97",
"256",
"353",
"garbage",
], 
 
[ 
// question 3 (answer 2)
"What conversion is usually applied to an array?",

"the value of an array is converted to the value of the first element of the array",
"the value of an array is converted to a pointer to the first element of the array",
"for a character array, the size of an array is converted to include the null pointer",
"the value of an array is converted to an integer type with at least the size of type int",

], 
 
[ 
// question 4 (answer 2)
"Choose the line where the usual array conversions ARE done (the three situations " +
	"where the conversions aren't performed are choices)\r\n\r\n" +
	"char str[ ] = \"hello\";",

"char str[ ] = \"hello\" /* initialization */",
"strlen(str)",
"&str",
"sizeof str",
], 
 
[ 
// question 5 (answer 3)
"How is the type char represented?",
"unsigned 8 bits",
"signed 8 bits",
"implementation defined with a minimum of 8 bits",
"implementation defined with a minimum of 16 bits",
], 
 
[ 
// question 6 (answer 3)
"What is the result of sizeof (s1) if the alignment requirement for " +
	"structures is the largest alignment requirement of any member. The " +
	"implementation's alignment restriction for int is 4. \r\n" +
	"                                                              " +
	"        struct { char a;\r\n" +
	"                                                                            " +
	"        int    b;    } s1;",
"4",
"5",
"8",
"16",
], 
 
[ 
// question 7 (answer 4)
"What is the type of this expression? \r\n\r\n" +
	"3 + 4.5",

"int",
"long",
"float",
"double",
], 
 
[ 
// question 8 (answer 3)
"What is the type of this expression? \r\n\r\n" +
	"'a'",

"char",
"short",
"int",
"float",
], 
 
[ 
// question 9 (answer 2)
"What is the type of \" arr \" in the expression \" arr[2] = 4; \" after evaluation? \r\n" +
	"     char arr[5]; \r\n" +
	"     arr[2] = 4;",

"char",
"pointer to char",
"int",
"array of char",
], 
 
[ 
// question 10 (answer 4)
"What is the type of \" arr \" in the expression \" sizeof (arr); \" after evaluation? \r\n" +
	"     char arr[5] \r\n\r\n" +
	"     sizeof (arr);",

"char",
"pointer to char",
"int",
"array of char",
], 
 
[ 
// question 11 (answer 3)
"What is the type of \" f \" in the expression \" f( ); \" after evaluation? \r\n" +
	"     void f(void); \r\n\r\n" +
	"     f( );",

"void",
"function returning void",
"pointer to a function returning void",
"pointer to void",
], 
 
[ 
// question 12 (answer 3)
"What is the type of \" f \" in the expression \" f2(f); \" after evaluation? \r\n" +
	"     void f(void); \r\n" +
	"     void f2(void (f*)(void)); \r\n" +
	"     f2(f);",

"void",
"function returning void",
"pointer to a function returning void",
"pointer to void",
], 
 
[ 
// question 13  (answer 4) - propagation of high-order bit when signed integer is shifted
// p. 232 ref p. 452 modern
"What is the result of this expression? \r\n\r\n" +
	"short x = -2; (represented in two-s complement) \r\n" +
	"                        1111 1111 1111 1110 \r\n" +
	"x >> 4; ",

"0000 1111 1111 1111",
"1111 1111 1111 1111",
"1111 1111 1111 1111",
"implementation defined",
], 
 
[ 
// question 14 (answer 1)
"Which p is NOT a null pointer?",

"int *p;",
"int *p = NULL;",
"int *p = 0;",
"int *p = 2 - 2;",
], 
 
[ 
// question 15 (answer 3)
"What are the three parts of a floating point number stored following the IEEE Floating " +
	"Standard (most computers use this representation)",

"sign",
"exponent",
"divisor",
"mantissa",
]
]

// Quiz 8 ****************** Bitwise Operators & Binary ***************

quiz8 = 
[
[

// question 1 (answer 2)
"What is the  \" ~ \" operator?",
"bitwise shift",
"bitwise one's complement",
"bitwise exclusive or",
"bitwise inclusive or",
], 
 
[ 
// question 2 (answer 4)
"What is the  \" | \" operator?",
"bitwise shift",
"bitwise one's complement",
"bitwise exclusive or",
"bitwise inclusive or",
], 
 
[ 
// question 3 (answer 1) 
"How is x represented in two's complement?\r\n\r\n" +
    "short x = -2;",

"1111 1111   1111 1110",
"1000 0000   0000 0010",
"1111 1111   1111 1101",
"1000 0000   0000 0001",
], 
 
[ 
// question 4 (answer 2)
"What is the one's complement of x?\r\n\r\n" +
    "unsigned char x = 8;",
"1111 1011",
"1111 0111",
"1111 1101",
"1110 1111",

], 
 
[ 
// question 5 (answer 2)
"What is printed?\r\n" +
	"     #define BYTE(x) ((x) >> (8))\r\n" +
	"     int x, y = 694;      /* y in binary: 10 1011 0110 */\r\n " +
	"     x = BYTE(y);\r\n" +
	"     printf(\"x: %d\", x);",

"1",
"2",
"3",
"4",
], 
 
[ 
// question 6 (answer 3)
"How do you set the 2nd bit of x leaving the rest of the representation " +
"unaltered?\r\n\r\n" +
    "unsigned short x = 0x4840;   (in binary 01001000 01000000)",
"x &= 2;",
"x ~= 2;",
"x |= 2;",
"x ^= 2;",
], 
 
[ 
// question 7 (answer 1)
"How do you clear the 2nd bit of x?\r\n\r\n" +
    "unsigned short x = 0x4842;   ( in binary 01001000 01000010 )",
"x &= ~ 2;",
"x &= | 2;",
"x |= ~ 2;",
"x ^= & 2;",
], 
 
[ 
// question 8 (answer 1)
"How do you test the 2nd bit of x?\r\n\r\n" +
    "unsigned short x = 0x4842;  ( in binary 01001000 01000010 )",
"if(x & 2) ...",
"if(x ~ 2) ...",
"if(x | 2) ...",
"if(x ^ 2) ...",
], 
 
[ 
// question 9 (answer 4)
"What is the result of ~ on x (8 bit char)? \r\n\r\n" +
	"unsigned char x = 0; \r\n\r\n" +
	"~x",

"1",
"127",
"128",
"255",
], 
 
[ 
// question 10 (answer 4)
"What is x initialized to? \r\n" +
	"#define RED   1 \r\n" +
	"#define GREEN   2 \r\n" +
	"#define BLUE   4 \r\n" +
	"unsigned short x = RED | BLUE;",

"1",
"2",
"4",
"5",
], 
 
[ 
// question 11 (answer 2)
"What is assigned to x? \r\n" +
	"#define GREEN    2 \r\n" +
	"#define BLUE     4 \r\n" +
	"unsigned int x = 6; \r\n" +
	"x &= ~BLUE;",
	
"0",
"2",
"4",
"6",
], 
 
[ 
// question 12 (answer 4) 
"What sets the bit field (bits 1 - 3 starting at 0) as shown? \r\n\r\n" +
	"set the bit field to: 101  resulting in 0010 1010 /* 42 in decimal */ \r\n\r\n" +
	"unsigned char x = 44;   /* 0010 1100 */",
	
"x = x | 10",
"x = x & 14 | 10",
"x = x & 10",
"x = x & ~14 | 10",
], 
 
[ 
// question 13 (answer 1)
"What is the result of this? \r\n\r\n" +
	"unsigned char x = 53387;    /* 1101 0000 1000 1011 */ \r\n\r\n" +
	"x << 4 >> 8;",

"8      /* 0000 1000 */",
"139    /* 1000 1011 */",
"208    /* 1101 0000 */",
"216    /* 1101 1000 */",

], 
 
[ 
// question 14 (answer 1)
"What is x? (char is 8 bits) \r\n\r\n" +
	"unsigned char x = ~0xF",

"1111 0000",
"1110 1111",
" 111 0000 ",
" 101 1111",
], 
 
[ 
// question 15 (answer 1)
"What is x? (char is 8 bits) \r\n\r\n" +
	"unsigned char x = 0xFF",

"1111 1111",
"1110 1111",
"1000 0000",
"1000 1000",
]
]

// Quiz 9 ****************** Preprocessor *****************************

quiz9 = 
[
[
// question 1 (answer 3)
"What is NOT done by the preprocessor?",

"macro definition",
"file inclusion",
"resolving external references",
"conditional compilation",
], 
 
[ 
// question 2 (answer 4)
"What is NOT one of the three operators specific to the preprocessor?",

"#",
"##",
"defined",
"macro",
], 
 
[ 
// question 3 (answer 4)
"What does the preprocessor operator  \" ## \" do?",

"denotes a comment",
"stringization",
"expands to a defined name",
"merges two tokens",
], 
 
[ 
// question 4 (answer 3)
"Which is illegal?",

"#include <stdio.h>",
"#       include <stdio.h>",
"include <stdio.h>",
"          #       include <stdio.h>",

], 
 
[ 
// question 5 (answer 1)
"What is printed? \r\n" +
	"     #define M(x, y) ((x) < (y) ? (x) : (y)) \r\n\r\n" +
	"     main( ) {    int a = 2, b = 5; \r\n" +
	"            printf(\"%d\", M(a, b))    }",

"2",
"3",
"5",
"15",
], 
 
[ 
// question 6 (answer 2) answer is 4 ( ternary operator ? : has sequence points )
"What is printed? \r\n" +
	"    #define M(x, y) ((x) < (y) ? (x) : (y)) \r\n\r\n" +
	"    main( ) {    int a = 2, b = 5; \r\n" +
	"           printf(\"%d\", M(++a, b));    }",

"3",
"4",
"5",
"15",
], 
 
[ 
// question 7 (answer 3)
"What is declared after this macro is expanded? \r\n\r\n" +
	"#define PTR_INT int * \r\n" +
	"PTR_INT a, b, c;",

"a of type int \r\n" +
	"b of type int \r\n" +
	"c of type int",
"a of type int *\r\n" +
	"b of type int * \r\n" +
	"c of type int *",
"a of type int *\r\n" +
	"b of type int \r\n" +
	"c of type int",
"a of type int *\r\n" +
	"b of type int *\r\n" +
	"c of type int ",
], 
 
[ 
// question 8 (answer 3) 
"What is NOT a predefined macro defined by Standard C?",

"__LINE__",
"__FILE__",
"__END__",
"__DATE__",
], 
 
[ 
// question 9 (answer 2)
"What does the preprocessor operator  \" # \" do?",
"denotes a comment",
"stringization",
"expands to a defined name",
"merges two tokens",
], 
 
[ 
// question 10 (answer 2)
"Which will \"condition out\" any preprocessor directives b/w the pair? \r\n\r\n" +
	"#define DEBUG 1",

"#if DEBUG \r\n" +
	"#endif",
"#ifndef DEBUG \r\n" +
	"#endif",
"#if defined DEBUG \r\n" +
	"#endif",
"#if defined(DEBUG) \r\n" +
	"#endif",
], 
 
[ 
// question 11 (answer 3)
"What does the preprocessor replace PR_INT(a / 2) with? \r\n\r\n" +
	"#define PR_INT(x)  printf(#x \" = %d\", x) \r\n" +
	"int a = 8; \r\n" +
	"PR_INT(a / 2);",

"printf( \"a\" \" = %d\", a / 2 )",
"printf( a / 2 \" = %d\", a / 2 )",
"printf( \"a / 2\" \" = %d\", a / 2 )",
"printf( \"a / 2 = %d\", a / 2 )",
], 
 
[ 
// question 12 (answer 2)
"What is y? (The macro definition includes a common mistake)\r\n\r\n" +
	"#define XTEN(x) (x * 10) \r\n\r\n" +
	"int y = XTEN(2 + 4); ",

"40",
"42",
"60",
"62",
], 
 
[ 
// question 13 (answer 3)
"What is y? (The macro definition includes a common mistake)\r\n\r\n" +
	"#define A3   3 * 2.2 \r\n\r\n" +
	"double y = 6.6 / A3; " ,

"1",
"2.2",
"4.84",
"6.6",

], 
 
[ 
// question 14 (answer 1)
"What is the null preprocessor statement?",

"#",
"##",
"NULL",
"#NULL",
], 
 
[ 
// question 15 (answer 3)
"Which is NOT a preprocessor directive?",

"#include",
"#line",
"#defined",
"#pragma",
]
];

// Quiz 10 ****************** Compiler and Linker **********************

quiz10 = 
[
[
// question 1 (answer 2)
"What does a linker do?",

"expands macros",
"resolves references between translation units",
"merges two tokens",
"expands include files and processes other commands",
], 
 
[ 
// question 2 (answer 3)
"What is a translation unit?", 

"object file created by the linker",
"token",
"source file after includes and conditional compilation",
"header file",
], 
 
[ 
// question 3 (answer 3) - these terms aren't defined in standard
"What is the correct order of the eight phases of translation? ",

"Character mapping,  Preprocessing,  Line splicing,  Tokenization,  Character-set mapping,  " +
	"String concatenation,  Translation,  Linkage", 
"Character mapping,  Line splicing,  Tokenization,  Preprocessing,  Character-set mapping,  " +
	"String concatenation,  Linkage,  Translation ", 
"Character mapping,  Line splicing,  Tokenization,  Preprocessing,  Character-set mapping,  " +
	"String concatenation,  Translation,  Linkage", 
"Character mapping, Line splicing, Tokenization, Character-set mapping " +
	"String concatenation,  Preprocessing,  Translation,  Linkage", 
], 
 
[ 
// question 4 (answer 2) - p. 116 ref
"What customarily happens when a declaration with external linkage for a function " +
	"or variable is not referenced?",

"the linker notices that it isn't referenced and doesn't load the function",
"the compiler notices that it isn't referenced and doesn't pass the external reference " +
	"to the linker",
"the linker includes all external references",
"the compiler passes all external references to the linker",
], 
 
[ 
// question 5 (answer 1)
"Which is stored on the stack?",

"main( ) \r\n" +
	"{ \r\n" +
	"       int x; \r\n" +
	"}",
"main( ) \r\n" +
	"{ \r\n" +
	"       static int x; \r\n" +
	"}",
"main( ) \r\n" +
	"{ \r\n" +
	"       extern x; \r\n" +
	"}",
"int x; \r\n" +
	"main( ) \r\n" +
	"{ \r\n" +
	"   /* ... */ }",
], 
 
[ 
// question 6 (answer 3)
"Which allocates space on the heap for the variable?",

"void f(void); \r\n\r\n" +
	"main( ) \r\n" +
	"{ /* ... */ }",
"main( ) \r\n" +
	"{ \r\n" +
	"       int x; \r\n" +
	"}",
"int x; \r\n\r\n" +
	"main( ) \r\n" +
	"{ /* ... */ }",

"extern int x; \r\n\r\n" +
	"main( ) \r\n" +
	"{ /* ... */ }",
], 
 
[ 
// question 7 (answer 3)
"What is printed? \r\n\r\n" +
	"int x = 5, y = 5; \r\n" +
	"x+++y; \r\n" +
	"printf(\"%d %d\", x, y); ",

"5 5",
"5 6",
"6 5",
"error",
], 
 
[ 
// question 8 (answer 2)
"What is printed? \r\n\r\n" +
	"int x = 5, y = 5; \r\n\r\n" +
	"printf(\"%d\", x+++y);",

"5",
"10",
"11",
"error",
], 
 
[ 
// question 9 (answer 4)
"What is printed? \r\n\r\n" +
	"int x = 5, y = 5; \r\n\r\n" +
	"printf(\"%d\", x+++++y);",

"5",
"10",
"11",
"error",
], 
 
[ 
// question 10 (answer 4)
"Which is legal?",

"++i++",
"i++--",
"(i++)++",
"+ ++i",

], 
 
[ 
// question 11 (answer 2)
"What is NOT done before preprocessing directives are executed?",

"comments are replaced by one space character",
"adjacent string literals are concatenated",
"trigraph sequences are replaced by corresponding single-character representations",
"line splicing is preformed - joining lines connected with a backslash and newline",
], 
 
[ 
// question 12 (answer 3)
"What category does this go into? \r\n\r\n" +
	"whether type char is signed or unsigned",

"Unspecified behavior",
"Undefined behavior",
"Implementation-defined behavior",
"Locale-specific behavior",
], 
 
[ 
// question 13 (answer 2)
"What category does this go into? \r\n\r\n" +
	"signed integer overflow",

"Unspecified behavior",
"Undefined behavior",
"Implementation-defined behavior",
"Locale-specific behavior",
], 
 
[ 
// question 14 (answer 1) - page 62
"What category does this go into? \r\n\r\n" +
	"the order in which the arguments to a function are evaluated",

"Unspecified behavior",
"Undefined behavior",
"Implementation-defined behavior",
"Locale-specific behavior",
], 
 
[ 
// question 15  (answer 2) - undefined p.77 footnote standard

"What category does this go into? \r\n\r\n" +
	"dereferencing a pointer that hasn't been initialized?",

"Unspecified behavior",
"Undefined behavior",
"Implementation-defined behavior",
"Locale-specific behavior",
]
];


var quizzes = 
[
quiz1, quiz2, quiz3, quiz4, quiz5, quiz6, quiz7, quiz8, quiz9, quiz10
];

// alert(quizzes[9][14][4]);

/************************************* Review *****************************/

var rev = 
[

[
// Quiz 1 ****************** Declarations *****************************

// question 1 (answer 3) checked

"Answer C: \r\n\r\n" + 

"unsigned is a different type than unsigned long and unsigned long int.\r\n\r\n" + 

"The type specifier unsigned, with no other type specifiers, declares an unsigned int, " + 
"not an unsigned long. \r\n\r\n" + 

"The nine integer types are shown below. The list of type specifiers used " + 
"in a declaration must be one of the comma delimited sets.  The type specifiers in each " + 
"list may be in any order.  " + 
"Each comma-delimited set declares the same type as the others on its line.\r\n\r\n" + 

"char \r\n" + 
"signed char \r\n" + 
"unsigned char \r\n" + 
"short,  signed short, short int, signed short int \r\n" + 
"unsigned short,  unsigned short int \r\n" + 
"int,  signed,  signed int \r\n" + 
"unsigned,  unsigned int \r\n" + 
"long,  signed long,  signed long int \r\n" + 
"unsigned long,  unsigned long int\r\n\r\n" + 

"For example: \r\n\r\n" + 
"long a; \r\n" + 
"signed long b; \r\n" + 
"signed long int c;\r\n\r\n" + 
"a, b, and c are declared with the same type.",


// question 2 (answer 2) checked
"Answer B: \r\n\r\n" + 

"When a storage class specifier is used in the declaration of a variable, it determines " + 
"the storage duration, scope, and linkage of the variable.  (functions are not " + 
"discussed here)\r\n\r\n" + 

"storage duration:\r\n" + 
"determines when memory is reserved for a variable and when that memory is " + 
"freed.  A variable can have either automatic storage duration or static storage duration.\r\n\r\n" + 

"scope:\r\n" + 
"determines where in a source file a variable can be referenced.  Variables can " + 
"have either file scope or block scope. \r\n\r\n" + 

"linkage:\r\n" + 
"determines whether a variable can be referenced from other source files.  " + 
"A variable can have external linkage, internal linkage, or no linkage. \r\n\r\n" + 

"The storage class specifier's effect on the storage duration, scope, and linkage is determined " + 
"by factors including the placement of the declaration in the file.  Placement " + 
"includes whether a declaration is in a function or outside of any function. ",

// question 3 (answer 2) checked (in review excluding typedef)
"Answer B:  \r\n\r\n" + 

"The storage class specifiers are:  \r\n\r\n" + 
"static\r\n" + 
"extern \r\n" + 
"auto \r\n" + 
"register \r\n\r\n" + 
"typedef \r\n" + 
"(typedef included here by the standard for convenience)",

// question 4 (answer 1) checked
"Answer A: \r\n\r\n" + 

"A.   int\r\n\r\n" + 
"is the type specifier.\r\n\r\n",

// question 5 (answer 4) checked
"Answer D: \r\n\r\n" + 

"D.   *x   \r\n\r\n" + 
"is the declarator (which in this case includes part of the type information " + 
"for x).  \r\n\r\n" + 
"A declarator is an identifier (the name of the variable or function) with an optional " + 
"* before it and ( ) or [ ] after it.  The optional symbols provide additional type information.",


// question 6 (answer 2) checked
"Answer B: \r\n\r\n" + 

"B.   int * \r\n\r\n" + 

"x is declared with type pointer to an int. \r\n\r\n" + 
"The type of x is determined by the type information in the declarator (* pointer) and " + 
"the type specifier (int).",

// question 7 (answer 3) checked - ref - std
"Answer C: \r\n\r\n" + 

"C.   char[ ]\r\n\r\n" + 

"\"hello\" is a string literal.  A string literal is stored as a null-terminated character " + 
"array.  \"hello\" has the type array of characters.  Storage for a string literal is " + 
"set aside at load-time.",

// question 8 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"B.   storage class specifier\r\n\r\n" + 
"static is a storage class specifier.",

// question 9 (answer 1) checked
"Answer A: \r\n\r\n" + 

"A.   type specifier\r\n\r\n" + 

"long is a type specifier.  \r\n\r\n" + 

"Examples:\r\n" + 
"long x;\r\n   (x has type long)\r\n" + 
"unsigned long y;\r\n   (y has type unsigned long) \r\n" + 
"long f(void);\r\n   (f has type function returning long) \r\n" + 
"long *p;\r\n   (p has type pointer to long)",

// question 10 (answer 2) checked
"Answer B: \r\n\r\n" + 

"B.   pointer to a function returning char \r\n\r\n" + 

"The declarator here is (*f)(void).  Without the parentheses, the type would be " + 
"function returning a pointer to a char.  The parentheses are used to override the higher precedence of " + 
"( ) over *.",

// question 11 (answer 1) checked
"Answer A:  \r\n\r\n" + 

"A.   f\r\n\r\n" + 

"The identifier is f.  There is always a single identifier as a component of the " + 
"declarator.",

// question 12 (answer 4) checked
"Answer D: \r\n\r\n" + 
"D.   * f(int, int)\r\n\r\n" + 

"The declarator includes the * and (int, int) giving type information for f.\r\n\r\n" + 
"( ) takes precedence over * .  The type is function returning a pointer to a char.",

// question 13 (answer 3) checked
"Answer C: \r\n\r\n" + 

"C.   array of pointers to functions returning pointer to an int \r\n\r\n" + 

"The declarator is   *(*x[5])(void)  \r\n\r\n" + 
"[ ] takes precedence over *, so the type category is array.  \r\n\r\nThen * tells us the type of " + 
"the elements of the array, pointers.  \r\n\r\nThen go right because ( ) takes precedence over *.  " + 
"We then have array of pointers to functions (with no arguments).  \r\n\r\nThen go left to find the return type. " + 
"The function returns a pointer to an int.",

// question 14 (answer 3) checked
"Answer C: \r\n\r\n" + 

"C.   enum a{ x, y, z}; \r\n\r\n" + 

"Enumeration constants do not make up a name space.  The enumeration constant x " + 
"would conflict with the x declared with  int x;  if declared in the same block.  \r\n\r\n" + 

"There are distinct name spaces for different categories of identifiers.  " + 
"For example, tags of structures, unions, and enumerations are in the same name space.\r\n\r\n" + 
"Different name spaces mean that the same identifier can be used for more than one " + 
"item if the items are in different name spaces.  Identifers must be unique in the same " + 
"namespace (if in the same block).",

// question 15 (answer 2) checked
"Answer B: \r\n\r\n" + 

"Identifiers in the same namespace may be \"hidden\" by declaring them in an " + 
"inner block.  The compound statement creates another block scope.  The declaration of " + 
"a in that block hides the declaration in the outer block.\r\n\r\n" + 
"The  a  in  int b = a;  is " + 
"bound to the inner block declaration: int a = 10; .",
],


[

// Quiz 2 ****************** Lexical Elements *************************

// question 1 (answer 2) checked
"Answer B:\r\n\r\n" + 

"There are two character sets required by Standard C.  One is the source character set " + 
"which is the set of characters used to write the source file.  The other is the execution " + 
"character set.  This is the set interpreted in the execution environment.  The values of " + 
"the members of the execution character set are implementation defined.  \r\n\r\n" + 
"The source and execution set may be " + 
"the same.  The most common character set is seven-bit ASCII " + 
"(American Standard Code for Information Interchange).",

// question 2 (answer 2) checked
"Answer B: \r\n\r\n" + 
"A line ending in a backslash followed by an end-of-line marker (usually created by " + 
"pressing return) creates a logical source " + 
"line out of the line with the backslash and the next line.  It splices these two physical " + 
"lines together to form a logical line.  This is probably most often used " + 
"in preprocessing directives.",

// question 3 (answer 4) checked
"Answer D: \r\n\r\n" + 

"Trigraphs are available so that source code can be written using only the Invariant Code Set. " + 
"The ISO 646-1083 Invariant Code Set is a set that is a subset of the 7-bit ASCII set and " + 
"is common to many non-English sets.  \r\n\r\n" + 
"Characters such as # and [ are not in some variants " + 
"of ASCII.  The trigraphs allow these symbols to be represented without using those characters.  " + 
"For example, the trigraph ????= is equivalent to #.",

// question 4 (answer 4) checked
"Answer D: \r\n\r\n" + 

"Standard C defines six tokens: \r\n\r\n" + 
"keyword\r\nidentifier\r\nconstant\r\nstring-literal\r\noperator\r\npunctuator \r\n\r\n" + 
"A token is a collection of characters that cannot be broken up without the collection " + 
"losing its meaning.",

// question 5 (answer 4) checked
"Answer D: \r\n\r\n" + 

"The radix (or base) of a constant can be one of the following: base 16 (hexadecimal), base 10 (decimal), " + 
"or base 2 (binary).  Hex is written beginning with either of the following: 0x, 0X.",

// question 6 (answer 2) checked
"Answer B: \r\n\r\n" + 

"A string literal is stored as a null-terminated character array.  In translation phase 7, " + 
"a value of zero (null character) is appended to each string literal.  The null character is " + 
"appended to the \\n (ASCII value 10) resulting in a 2 element array.",

// question 7 (answer 4) checked
"Answer D: \r\n\r\n" + 

"The number of spaces that the  \\t  escape sequence advances is not defined by the standard.  " + 
"This is determined by the operating system.",

// question 8 (answer 2) checked
"Answer B: \r\n\r\n" + 

"There are two specific definitions of main in the standard.  The first has a return " + 
"type of int and no parameters.  The second returns an int and has two parameters.  The first " + 
"parameter is of type int (or equivalent using typedef for ex.) and the second is " + 
"char ** (or equivalent).  The standard has additional restrictions and does allow " + 
"implementation defined definitions.",

// question 9 (answer 1) checked
"Answer A: \r\n\r\n" + 

"\\a  produces an alert (audio or visual).",

// question 10 (answer 2) checked
"Answer B: \r\n\r\n" + 

"\\a   (alert) \r\n" + 
"\\b   (backspace) \r\n" + 
"\\f   (form feed) \r\n" + 
"\\n   (new line) \r\n" + 
"\\r   (carriage return) \r\n" + 
"\\t   (horizontal tab) \r\n" + 
"\\v   (vertical tab) \r\n",

// question 11 (answer 3) checked
"Answer C: \r\n\r\n" + 

"A. '\\0'   This is the null character as a character constant. \r\n\r\n" + 
"B. NULL    Standard C requires there be a macro NULL defined as an implementation-defined " + 
"null pointer constant. The null pointer constant is either 0 or an expression with the " + 
"value 0 cast to (void *).  NULL is usually defined in <stddef.h> and additional header " + 
"files.\r\n\r\n" + 
"C. \"0\"   This is a string literal which (with few exceptions) evaluates to a pointer " + 
"to the first character in the array, the character 0 (ASCII value 48) in this case.  " + 
"The value of the expression \"0\" is an address. \r\n\r\n" + 
"D. 0x0   This is 0 written with a hexadecimal prefix, 0x.",

// question 12 (answer 4) checked
"Answer D: \r\n\r\n" + 

"Identifiers cannot begin with any of the following: \r\n\r\n0 1 2 3 4 5 6 7 8 9\r\n\r\n",

// question 13 (answer 2) checked
"Answer B: \r\n\r\n" + 

"wchar_t   is a two-byte character used to write portable programs for foreign languages.",

// question 14 (answer 2) checked
"Answer B: \r\n\r\n" + 

"A.   American National Standard X3J11\r\n" + 
"The committee formed in 1982 to standardize C.  This committee eventually produced " + 
"\"ANSI C\". \r\n\r\n" + 

"B.   American National Standard X3.159-1989\r\n" + 
"This is ANSI C. \r\n\r\n" + 

"C.   IS0/IEC 9899:1990 \r\n" + 
"A few small changes were made to ANSI C and adopted as this international standard.  The " + 
"ISO is the International Organization for Standardization.  ISO is not an acronym.  Because " + 
"the abbreviation of the name would be different in many languages, ISO decided to base " + 
"their name on the Greek \"iso\", meaning \"equal\".  IEC stands for " + 
"International Electrotechnical Commission.  The ISO and IEC together formed a standards " + 
"body for the international standardization of programming languages.  This is the " + 
"ISO/IEC JTC1/SC22/WG14.  " + 
"{ JTC(Joint Technical Committee) SC(Subcommittee) WG(Working Group)  }  " + 
"This group adopted the ANSI standard with a few small changes.  The product was " + 
"IS0/IEC 9899:1990.\r\n\r\n" + 

"D.   IS0/IEC 9899:1999 \r\n" + 
"This is the current international standard.  Presently, ANSI has not adopted this as a standard.  " + 
"Some additions and changes are made.  However, the fundamentals are not changed. ",

// question 15 (answer 3) checked
"Answer C: \r\n\r\n" + 

"A.   American National Standard X3.159-1989\r\n" + 
"This is ANSI C. \r\n\r\n" + 

"B.   ISO/IEC JTC1/SC22/WG14\r\n" + 
"The ISO and IEC together formed a standards " + 
"body for the international standardization of programming languages.  This is the " + 
"ISO/IEC JTC1/SC22/WG14.  " + 
"{ JTC(Joint Technical Committee) SC(Subcommittee) WG(Working Group)  }  " + 
"This group adopted the ANSI standard with a few small changes.  The product was " + 
"IS0/IEC 9899:1990.\r\n\r\n" + 

"C.   IS0/IEC 9899:1990 \r\n" + 
"A few small changes were made to ANSI C and adopted as this international standard.  The " + 
"ISO is the International Organization for Standardization.  ISO is not an acronym.  Because " + 
"the abbreviation of the name would be different in many languages, ISO decided to base " + 
"their name on the Greek \"iso\", meaning \"equal\".  IEC stands for " + 
"International Electrotechnical Commission.  The ISO and IEC together formed a standards " + 
"body for the international standardization of programming languages.  This is the " + 
"ISO/IEC JTC1/SC22/WG14.  " + 
"{ JTC(Joint Technical Committee) SC(Subcommittee) WG(Working Group)  }  " + 
"This group adopted the ANSI standard with a few small changes.  The product was " + 
"IS0/IEC 9899:1990.\r\n\r\n" + 

"D.   IS0/IEC 9899:1999 \r\n" + 
"This is the current international standard.  Presently, ANSI has not adopted this as a standard.  " + 
"Some additions and changes are made.  However, the fundamentals are not changed. ",
],

[

// Quiz 3 ****************** Types ************************************

// question 1 (answer 3) checked
"Answer C:  \r\n\r\nA pointer is a scalar type.\r\n\r\nA scalar type is capable of holding a single value.  An aggregate type can hold a " + 
	"collection of values.  Arithmetic and pointer types are scalar.  Array and " + 
	"structures types are aggregate types.  \r\n\r\nArithmetic types: \r\n    integral types\r\n" + 
	"    floating-point types \r\n\r\nIntegral types: \r\n    char (signed and unsigned)\r\n" + 
	"    short, int, long (signed and unsigned)\r\n    enum\r\n\r\nFloating-point types: \r\n" + 
	"    float\r\n    double\r\n    long double",

// question 2 (answer 3) checked
"Answer C:  \r\n\r\nAn array is an aggregate type.\r\n\r\n" + 
	"A scalar type is capable of holding a single value.  An aggregate type can hold a " + 
	"collection of values.  Arithmetic and pointer types are scalar.  Array and " + 
	"structures types are aggregate types.  \r\n\r\nArithmetic types: \r\n    integral types\r\n" + 
	"    floating-point types \r\n\r\nIntegral types: \r\n    char (signed and unsigned)\r\n" + 
	"    short, int, long (signed and unsigned)\r\n    enum\r\n\r\nFloating-point types: \r\n" + 
	"    float\r\n    double\r\n    long double",

// question 3 (answer 2) checked
"Answer B:  \r\n\r\nThis string literal evaluates to a pointer.\r\n\r\n" + 
	"A string literal is a character array.  Arrays evaluate to pointers with three " + 
	"exceptions:\r\n\r\n" + 
	"1.  the array is the operand of the sizeof operator\r\n\r\n" + 
	"2.  the array is the operand of the & (address of) operator\r\n\r\n" + 
	"3.  a string literal is used to initialize an array",

// question 4 (answer 4) checked
"Answer D:  \r\n\r\n" + 
	"\"hello\" is a string literal which is a character array.  There is a block of " + 
	"storage set aside at load-time for a 6 element array of elements of type char. (6 bytes) " + 
	"The characters are 5 letters and the \\0 (null character) terminating the string.",

// question 5 (answer 2) checked
"Answer B: \r\n\r\n" + 
	"The subscript operator [ ] definition is that [E1][E2] is identical to (*((E1) + (E2))).  " + 
	"(this general definition allows complex expressions as operands) " + 
	"E stands for expression.   \r\n\r\nOne of the expressions needs to evaluate to a pointer " + 
	"and the other an integer. (An array is converted to a pointer to the first element " + 
	"of the array with a few exceptions.) " + 
	"The conversion rules for the + operator state that if a pointer is added " + 
	"to an integer, the integer is \"scaled\" according to the type of the pointer.  " + 
	"That scaled integer is then added to the pointer.   \r\n\r\nFor example: \r\n\r\n" + 
	"int arr[10]; \r\n" + 
	"arr[2];  is rewritten as *(arr + 2) \r\n\r\n" + 
	"arr is converted to a pointer and 2 is scaled to the size of an int.\r\n\r\nIf the machine " + 
	"has a 4 byte int, then 2 is scaled like this:\r\n\r\n (2 * 4 bytes) resulting in 8.\r\n\r\n" + 
	"so after scaling, 8 is added to arr.",

// question 6 (answer 2) checked
"Answer B: \r\n\r\n" + 
	"3[arr] is equivalent to arr[3].  This is because the subscript operation is rewritten " + 
	"as:\r\n\r\n " + 
	"*(3 + arr)\r\n\r\n" + 
	"Likewise, arr[3] is rewritten as: \r\n\r\n" + 
	"*(arr + 3)\r\n\r\n" + 
	"Because addition is commutative, these are equivalent.",

// question 7 (answer 3) checked
"Answer C:\r\n\r\n" + 
"&a[0]   This evaluates to a pointer to the first element of the array.\r\n\r\n" + 
"A.   a\r\n" + 
"This evaluates to a pointer to the first element of the array.\r\n\r\n" + 

"B.   &a  \r\n" + 
"When the & (address of) operator is applied to an array name, the array name is NOT " + 
"converted to a pointer.  The result is the address of the first element of the array.\r\n\r\n" + 

"C.   *a \r\n" + 
"This evaluates to a type int.  \"a\" evaluates to a pointer to the first element of the array and is dereferenced getting " + 
"the value stored in the first element which is of type int.  The result is NOT a pointer like the " + 
"others.\r\n\r\n" + 

"D.   &*a \r\n" + 
"The standard specifically defines what happens when & and * are applied to each other " + 
"(they cancel out).  The result is \"a\" which evaluates to a pointer to the first element of " + 
"the array.",

// question 8 (answer 4) checked
"Answer D:\r\n\r\n" + 
"int * const p;\r\n\r\nconst gives constness to the pointer in this declaration, not the object pointed to.  The " + 
"value of p cannot be changed.  The value of the object that p points to can be changed.\r\n\r\n" + 
"Alternatively:  \r\n\r\n" + 
"const int * p;\r\n\r\n" + 
"declares a pointer to a const int.  The " + 
"value of p can be changed.  The value of the object that p points to cannot be changed.",

// question 9 (answer 4) checked
"Answer D:\r\n\r\n" + 
"A.   extern arr[ ];\r\n" + 
"declares an array of unknown size which is an incomplete type\r\n\r\n" + 

"B.   extern const arr[ ];\r\n" + 
"also declares an array of unknown size which is an incomplete type\r\n\r\n" + 

"C.   struct sTag;\r\n" + 
"declares a structure of incomplete type - the structure content is given elsewhere \r\n\r\n" + 

"D.   enum color { RED, GREEN, BLUE };\r\n" + 
"declares an enumerated type that is complete",

// question 10 (answer 3) checked
"Answer C: \r\n\r\n" + 
"A.  is a declarator \r\n\r\n" + 
"B.  is a keyword used in a declaration \r\n\r\n" + 
"C.  is the type specifier that is used to declare a tag and/or a variable \r\n\r\n" + 
"D.  includes BOTH the declarator s1 and the type specifier",

// question 11 (answer 3) checked
"Answer C: \r\n\r\n" + 
"A.  extern char arr[ ];\r\n" + 
"This is a declaration of an incomplete type that is defined elsewhere " + 
"if it is to be referenced.\r\n\r\n" + 

"B.  void f(void);\r\n" + 
"This is a function declaration (prototype).  A function definition includes " + 
"the body.  Storage is not \"reserved\" for a function in the same sense as for objects.\r\n\r\n" + 

"C.  int (*f)(void); \r\n" + 
"This declares a pointer to a function.  Storage is reserved for a " + 
"pointer.\r\n\r\n" + 

"D.  enum color { RED, BLUE, GREEN };  \r\n" + 
"This declares an enumeration tag that, like a structure " + 
"tag, reserves no storage (unless a variable is declared in the same declaration after the " + 
"body, and it isn't here).  The tag is used to declared variables after the tag is declared.",

// question 12 (answer 1) checked
"Answer A: \r\n\r\n" + 

"A.  extern int x = 4; \r\n" + 
"This is a definition of an int type with external linkage.  Storage " + 
"is reserved for an int (usually 2 or 4 bytes, depending on the word size used by the " + 
"machine).  Without " + 
"the initializer, it would an external reference to an x defined elsewhere. \r\n" + 
"int x = 4;  (at file scope) would be equivalent to extern int x = 4;\r\n\r\n" + 

"B.  (see left)\r\n" + 
"This is a structure tag declaration used to define variables later. \r\n\r\n" + 

"C.  void f(void);\r\n" + 
"This is a function declaration (prototype).  A function definition includes " + 
"the body.  Storage is not \"reserved\" for a function in the same sense as for objects.\r\n\r\n" + 

"D.  enum color { RED, BLUE, GREEN }; \r\n" + 
"This declares an enumeration tag that, like a structure " + 
"tag, reserves no storage (unless a variable is declared in the same declaration after the " + 
"body, and it isn't here).  The tag is used to declared variables after the tag is declared.",

// question 13 (answer 1) checked
"Answer A: \r\n\r\n" + 

"An integer constant followed by an   L   or   l (lowercase \"el\")  indicates that the " + 
"minimum size for a constant is to be the width of type long. ",

// question 14 (answer 4) checked
"Answer D: \r\n\r\n" + 
"The size of an int is dependent on the machine's \"word\" size. The meaning of \"word\" size " + 
"here is the natural size that the machine uses to communicate.  This is usually 16 or 32 bits.  " + 
"The standard requires that the size of an int be documented in the <limits.h> file.",

// question 15 (answer 3) checked
"Answer C: \r\n\r\n" + 
"C.   long float x; \r\n\r\n" + 
"Following Standard C, combining the type specifiers long and float does not declare any type.  " + 
"It is not a valid combination of type specifiers.  Some pre-Standard compilers allowed long float as a synonym for double.  Some modern compilers " + 
"permit it and give a warning.", 
],

[
// Quiz 4 ****************** Expressions ******************************

// question 1 (answer 3) checked
"Answer C: \r\n\r\n" + 

"Expression evaluation may cause \"side effects\".  One example of a side effect is " + 
"changing an objects value (e.g. using the assignment (=) or increment (++) operator). Another " + 
"example is the function call.  \r\n\r\n" + 
"The standard defines certain points in execution where all " + 
"side effects of previous evaluations must be complete and no side effects of later evaluations " + 
"will have happened.  An example of a sequence point is the end of an " + 
"expression statement. \r\n\r\n" + 
"ex. \r\n" + 
"int b = 2;\r\n" + 
"a = b++ + b++;\r\n\r\n" + 
"We don't know when the increments are done in the statement, but they must be done by the next sequence " + 
"point.  That is the semicolon in this case.  b must be incremented twice after that point.  " + 
"We don't know if b was incremented before of after it is added to itself.  The order in " + 
"which side effects happen is unspecified.  It is usually advisable to avoid modifying the value " + 
"of an object twice between sequence points.",

// question 2 (answer 4) checked
"Answer D: \r\n\r\n" + 

"The short circuiting operators  are  &&, ||, and ?: .  The end of the first operand of these " + 
"operators is a sequence point. \r\n\r\n" + 
"For example:\r\n\r\n" + 
"int x = 5; \r\n" + 
"if( x || y) \r\n\r\n" + 
"x is evaluated as true which makes the condition true so y is not evaluated.  This is " + 
"short circuiting.  If y has some side effect, it will not happen because it is not evaluated " + 
"in this case. ",

// question 3  (answer 1) checked - c99 d.2.3 - standard
"Answer A: \r\n\r\n" + 

"In the controlling expression:  \r\n" + 
"( x == 0  ||  ++y ) \r\n\r\n" + 
"x == 0    evaluates to true, so the logical OR operation is short circuited and " + 
"y is not incremented.",

// question 4 (answer 2) checked
"Answer B: \r\n\r\n" + 

"In the controlling expression:  \r\n" + 
"( x == 1  &&  ++y ) \r\n\r\n" + 
"x == 1 evaluates to true, so the logical AND operation doesn't short circuit and needs " + 
"to evaluate the second operand ++y to see if both operands are true.  So, y is incremented " + 
"and its value is 1 after the expression.",

// question 5 (answer 3) checked
"Answer C: \r\n\r\n" + 

"An object is a region of storage in the execution environment where values can be stored. ",

// question 6 (answer 2) checked
"Answer B: \r\n\r\n" + 

"An lvalue is an expression that refers to an object so that it may be examined or changed " + 
"(sometimes the value cannot be changed).  The l stands for left.  The term comes from " + 
"calling expressions on the left side of an assignment expression lvalues.  This is just " + 
"the origin of the term, not the definition.  lvalues can appear elsewhere and be " + 
"non-modifiable.\r\n\r\n" + 
"A.   f\r\n" + 
"This identifier is a function designator, it does not designate an object. \r\n\r\n" + 
"B.   color\r\n" + 
"This identifier designates an object with an enumeration type.  color can hold integer values.\r\n\r\n" + 

"C.   s1\r\n" + 
"This identifier is a structure tag that is used to declare variables. \r\n\r\n" + 

"D.   5L\r\n" + 
"This is a constant that has type long because of the postfix L.",

// question 7 (answer 3) checked
"Answer C: \r\n\r\n" + 

"arr is an array name.  An array name is an lvalue, but is not a modifiable lvalue.  " + 
"The array name usually evaluates to a pointer to the first array element.  This pointer " + 
"value cannot be altered.",

// question 8 (answer 4) checked
"Answer D: \r\n\r\n" + 

"D.   const int *p;\r\n\r\n" + 
"p is a pointer to a const int.  This declares a pointer that points to " + 
"a non-modifiable lvalue. The const is not applied to p.  The value stored in p can be changed.",

// question 9 (answer 2) checked
"Answer B: \r\n\r\n" + 

"The term rvalue is often used for non-lvalue expressions.  The r stands for right.  It can be " + 
"used only on the right-hand side of an assignment.",

// question 10 (answer 1) checked
"Answer A:  \r\n\r\n" + 

"A. tu\r\n\r\n" + 

"char *p = arr;   initializes p to point to the first character in the arr " + 
"character array. \r\n\r\n" + 
"*p   The for loop tests this condition.  It increments it by 2 every iteration.\r\n\r\n" + 
"p begins pointing to t, then points to u, then points to the null character so the test fails " + 
"and loop is ended.",

// question 11  (answer 3) checked - modern chapter 4
"Answer C: \r\n\r\n" + 

"C.   ; \r\n\r\n" + 
"This is the null statement.  This is termed an expression statement, but has no " + 
"expression. \r\n\r\n" + 

"Any expression can be made into a statement by adding a semicolon to it.  Some statements " + 
"like this may not do anything.  The standard permits " + 
"compilers to not generate code in such situations.  All these would qualify.  \r\n\r\n",

// question 12 (answer 3) checked 
"Answer C:  \r\n\r\n" + 

"if( x = 5 )  x-- ;\r\n\r\n" + 
"(x = 5)   the likely typing error is that this is meant to be x == 5.\r\n" + 
"x is assigned 5.  The assignment expression evaluates to 5 which evaluates true.\r\n" + 
"So, x (now 5 after assignment) is then decremented resulting in 4.",

// question 13  (answer 1) checked - p. 247 Ref and 6.3.2.1  - p. 39 standard
"Answer A: \r\n\r\n" + 

"If an lvalue has a qualified type, the value after evaluation of the lvalue (in this " + 
"and most contexts) has the unqualified type of the lvalue." + 
"",

// question 14  (answer 2) checked - p. 95 modern p. 249 ref
"Answer B: \r\n\r\n" + 

"++a   The first expression in the parameter list following the format string is paired  " + 
"with the first (and only) conversion specification.  " + 
"The increment is a prefix so the result of the operation is the a + 1.  Since there are more " + 
"items in the value list than there are conversion specifications, the extra value is not " + 
"shown.  ",

// question 15 (answer 3) checked
"Answer C: \r\n\r\n" + 

"The parameter after the format string is:\r\n\r\n" + 
"(++a, a + 5)\r\n\r\n" + 
"The parentheses create one parameter.  It is an expression using the comma operator.  The " + 
"comma operator has a sequence point at every comma.  Thus, the increment operation " + 
"in  ++a  is guaranteed to have been done when a is evaluated in  a + 5 .  The result of " + 
"the comma operator is the value of the right operand.  So, the result of the expression: \r\n\r\n" + 
"(++a, a + 5)   is 7.",
],

[
// Quiz 5 ****************** Statements *******************************

// question 1  (answer 3) checked p.261 ref can be not evaluated
"Answer C: \r\n\r\n" + 

"x + 5; \r\n\r\n" + 
"doesn't have a side effect.  The compiler can choose not to generate code for this.",

// question 2 (answer 1) checked - p. 260 Ref "any expression can be made a statement... add ;" + 
"Answer A: \r\n\r\n" + 

"int x; \r\n\r\n" + 
"is not a statement.  This is a declaration.",

// question 3 -  (answer 2) checked printf is the body
"Answer B: \r\n\r\n" + 

"The for loop tests  x--  on each iteration.  When x reaches zero, the loop ends.  " + 
"x-- uses the postfix decrement, so getting the value of the expression x-- doesn't " + 
"include subtracting " + 
"one from x.  That is guaranteed to be done by the next sequence point.  \r\n\r\n" + 
"On the last iteration, the expression x-- evaluates to 1.  " + 
"In the printf call, x has been decremented to 0.  The next test evaluates to 0.",

// question 4 (answer 2) checked - p. 13 modern
"Answer B: \r\n\r\n" + 

"struct s s1;\r\n\r\nThis is not a statement.  It is a declaration.",

// question 5 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The ternary operation is:\r\n\r\n" + 
"b ? c : d \r\n\r\n" + 
"The result is then assigned to a.  \r\n\r\nb is tested.  If it evaluates to true, c is the result.  " + 
"If it evaluates to false, d is assigned to a.",

// question 6 (answer 3) checked 
"Answer C \r\n\r\n" + 

"A case label is not a jump statement.  Control is transferred to a case label during execution " + 
"of a switch statement.  The execution then proceeds through the next statements.  Other case " + 
"labels are ignored.  \r\n\r\n" + 
"Control may be transferred by a break or another jump statement.  If " + 
"control is not transferred, then execution continues until the end of the switch statement.",

// question 7 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"A for loop is an iterative statement.",

// question 8 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"A switch statement is a selection statement.",

// question 9 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"A return statement is a jump statement.",

// question 10 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"On the first iteration, the test ( !i ) passes when i is 0.  The continue statement is " + 
"executed and control is passed to the end of the loop body.  count is not incremented that " + 
"iteration.  " + 
"The next two iterations increment count.",

// question 11  (answer 4) checked 
"Answer D: \r\n\r\n" + 

"The outer loop iterates 10 times.  The inner loop iterates 5 times for each outer loop.  " + 
"This makes count 50 after exiting the outer loop.",

// question 12 (answer 2) checked 
"Answer B:  \r\n\r\n" + 

"count is 10 after this do while statement.",

// question 13 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The choices that are legal have no effect.  The compiler can choose not to generate " + 
"code for them.\r\n\r\n" + 

"A.   ((( 5 )));\r\n" + 
"This is a legal use of grouping parentheses around an expression.\r\n\r\n" + 

"B.   (((( ))));\r\n" + 
"This is illegal because the grouping parentheses must group an expression.\r\n\r\n" + 

"C.   {{{ 5; }}};  \r\n" + 
"This is a valid use of curly braces to create compound statements.  Each pair also creates a " + 
"block.\r\n\r\n" + 

"D.   {{{{ }}}}; \r\n" + 
"This is a valid use of curly braces to create compound statements.  Each pair also creates a " + 
"block.  The compound statement can have zero statements.",


// question 14 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The choices that are legal have no effect.  The compiler can choose not to generate " + 
"code for them.\r\n\r\n" + 

"A.   5,5,5,5,5; \r\n" + 
"This is a legal use of the comma operator. \r\n\r\n" + 

"B.   {{{ 5 }}}; \r\n" + 
"This is illegal.  5 is not a statement.  Compound statements group statements, not " + 
"expressions.  The braces create 3 compound statements.  The " + 
"innermost compound statement contains an expression.  A semicolon could be added after the 5 " + 
"to create a legal (although useless) statement.\r\n\r\n" + 

"C.   {{{(5);}}};\r\n" + 
"This is a legal use of curly braces to create compound statements.  The innermost pair " + 
"holds an expression statement  (5); .  The expression 5 is grouped with parentheses. \r\n\r\n" + 

"D.   ((( 5 )));\r\n" + 
"This is a legal use of grouping parentheses around an expression.\r\n\r\n",

// question 15 (answer 3) checked - 3 prefix increment
"Answer C: \r\n\r\n" + 

"++-x  \r\n\r\n" + 
"is illegal because the decrement (and increment) operator needs an lvalue as its operand.  " + 
"After applying the unary minus operator, the value is not an lvalue.  Choices A, B, " + 
"and D are multiple unary minus and plus operations.",
],

[
// Quiz 6 ****************** Functions ********************************

// question 1 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"An activation record is a data structure containing the variables belonging to one particular " + 
	"invocation of a function.  \r\n\r\n" + 
	"Each time a function is called, an activation record is " + 
	"created on the stack with a copy of the function variables.  If a function is called " + 
	"recursively, an activation record is created for each call with its own copy of the " + 
	"function variables.",

// question 2 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"When a prototype is not used, the compiler is forced to make some assumptions.  The " + 
"compiler uses an implicit " + 
"declaration of the function as extern returning int. ",

// question 3 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"Each argument is implicitly converted to the type of the corresponding " + 
    "parameter as if by assignment.  ",

// question 4 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"Float arguments are converted to double and\r\n" + 
    "char and short arguments are promoted to int (or unsigned int in some situations).  The " + 
	"promotions of types char and short to type int are called integral promotions.",

// question 5 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"f is a function returning a pointer to a char.",

// question 6 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"The parentheses override the precedence of the function parentheses making a pointer " + 
"to a function returning void.",

// question 7 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The array name arr is always passed as a pointer to a function.  4 is the size of " + 
"a pointer to an int (assuming a pointer to an int on this machine is represented in " + 
"4 bytes).", 


// question 8  (answer 4) checked - p. 167 ref
"Answer D: \r\n\r\n" + 

"This is an error.  When a function designator is the operand of the sizeof operator, " + 
"the function designator is not converted to a pointer.  The sizeof operator applied " + 
"to a function designator is illegal and produces an error.",

// question 9 (answer 1) checked
"Answer A: \r\n\r\n" + 

"There is just one copy of code loaded into memory for each function regardless of the " + 
"amount of calls made to it.  \r\n\r\n" + 
"Each call does create an activation record which holds " + 
"its own copy of the function variables.",

// question 10 (answer 2) checked
"Answer B: \r\n\r\n" + 
"f has internal linkage.\r\n\r\n" + 

"f is declared outside of any function with the static storage class specifier.  This " + 
"gives f internal linkage.",

// question 11 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"f has external linkage.\r\n\r\n" + 
"f is a function declaration without a storage class specifier.  A function declaration " + 
"without a storage class specifier defaults to extern.",

// question 12 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The order in which the arguments of a function call are pushed onto the stack is determined " + 
"by the calling convention. \r\n\r\n" + 
"The calling convention also determines whether the callee (the " + 
"function called) or the caller (where the function was called) pops the arguments from " + 
"the stack.  This is called cleaning the stack.  This is done when the function is returning " + 
"control back to its caller.",

// question 13 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"The return value is 5.\r\n\r\n" + 

"f(5) finds that x is not equal to 1, so calls \r\n" +
	"f(4) finds that x is not equal to 1, so calls \r\n" + 
		"f(3) finds that x is not equal to 1 so calls \r\n" + 
			"f(2) finds that x is not equal to 1 so calls \r\n" + 
				"f(1) finds that x IS equal to 1 so returns 1 causing \r\n" + 
			"f(2) to return 1 + 1 = 2, causing \r\n" + 
		"f(3) to return 1 + 2 = 3, causing \r\n" + 
	"f(4) to return 1 + 3 = 4, causing  \r\n" + 
"f(5) to return 1 + 4 = 5",


// question 14 (answer 3) checked
"Answer C: \r\n\r\n" + 

"void x; \r\n\r\n" + 

"void cannot be used in this form.",

// question 15 (answer 3) checked
"Answer C: \r\n\r\n" + 

"void f(void *); \r\n\r\n" + 

"void *   is a generic pointer which allows any pointer type to be passed as an argument.",
],

[
// Quiz 7 ****************** Conversions and Representations **********

// question 1 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"Unless a prefix is used, the type of a floating-point constant is double.  A " + 
"floating-suffix can be added to determine the minimum size of the constant.  " + 
"F or f may be added for float.  L or l may be added for long double.",

// question 2 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"int x = 353;\r\n" + 
"represented in binary      1  0110 0001 \r\n\r\n" + 
"char *p = (char *)&x;\r\n" + 
"initializes p with a pointer to an int (cast to a char *)\r\n\r\n" + 
"p is then dereferenced and the result is assigned to y.  Since the pointer is of type " + 
"pointer to a char, the dereference only uses one byte (8 bits) and the result is 97.",

// question 3 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The value of an array is usually converted to a pointer to the first element of " + 
"the array.\r\n\r\n" + 
"There are three situations where the conversion to a pointer does not take place.\r\n\r\n" + 
"1. the array is an operand to the sizeof operator \r\n\r\n" + 
"2. the array is an operand to the & (address of) operator\r\n\r\n" + 
"3. a string literal is used to initialize a character array ",

// question 4 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"strlen(str)\r\n" + 
"str is converted to a pointer.\r\n\r\n" + 

"There are three situations where the conversion to a pointer does not take place.\r\n\r\n" + 
"1. the array is an operand to the sizeof operator \r\n\r\n" + 
"2. the array is an operand to the & (address of) operator\r\n\r\n" + 
"3. a string literal is used to initialize a character array ",

// question 5 (answer 3) checked
"Answer C: \r\n\r\n" + 

"The size of the char is implementation defined with a minimum of 8 bits (almost all " + 
"implementations use 8 bits).  Whether a char is signed or unsigned is also implementation " + 
"defined.  An implementation documents char information in the <limits.h> file. ",

// question 6 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"Some machines require that structure members begin on a multiple of some number of bytes.  " + 
"This is called an alignment requirement.  \r\n\r\n" + 

"In this case the alignment requirement in that " + 
"of the largest member, which is an int.  The requirement is 4.  So the char member is " + 
"stored in 4 bytes, including 3 padding bytes.",

// question 7 (answer 4) checked
"Answer D: \r\n\r\n" + 

"double \r\n\r\n" + 

"The integer constant 3 is converted to type double so a common type is used for the " + 
"arithmetic operation.  \r\n\r\n" + 
"There are complex rules defined in the standard for conversions.  " + 
"A general rule is that for most binary operators, the narrower type is converted to the wider " + 
"type.  Wider can mean more bits for the representation.  Wider can also mean an " + 
"unsigned type.  \r\n\r\n" + 
"For example, a short is wider than a char because a short uses more " + 
"bits for its representation.  Also, an unsigned char is considered wider than a signed " + 
"char.  It can hold a larger number because the signed representation uses a bit for the " + 
"sign.",

// question 8 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"A character constant is an integral type.  \r\n\r\n" + 
"Unless it begins with the prefix L, a " + 
"constant has type int.",

// question 9 (answer 2) checked
"Answer B: \r\n\r\n" + 

"The type is pointer to char. \r\n\r\n" + 

"Arrays evaluate to pointers with three " + 
	"exceptions:\r\n\r\n" + 
	"1.  the array is the operand of the sizeof operator\r\n\r\n" + 
	"2.  the array is the operand of the & (address of) operator\r\n\r\n" + 
	"3.  a string literal is used to initialize an array",

// question 10 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"The type is array of char.  The array is not converted to a pointer. \r\n\r\n" + 

"Arrays evaluate to pointers with three " + 
	"exceptions:\r\n\r\n" + 
	"1.  the array is the operand of the sizeof operator\r\n\r\n" + 
	"2.  the array is the operand of the & (address of) operator\r\n\r\n" + 
	"3.  a string literal is used to initialize an array",

// question 11 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"The type is pointer to a function returning void.\r\n\r\n" + 

"f is a function designator.  A function designator is converted to a pointer to a function " + 
"with 2 exceptions.\r\n\r\n" + 
"1.   the function designator is the operand of the sizeof operator\r\n\r\n" + 
"2.   the function designator is the operand of the & (address of) operator",

// question 12 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"The type is pointer to a function returning void.\r\n\r\n" + 
"f is a function designator.  A function designator is converted to a pointer to a function " + 
"with 2 exceptions.\r\n\r\n" + 
"1.   the function designator is the operand of the sizeof operator\r\n\r\n" + 
"2.   the function designator is the operand of the & (address of) operator",

// question 13  (answer 4) checked - propagation of high-order bit when signed int is shifted
// p. 232 ref p. 452 modern
"Answer D: \r\n\r\n" + 

"What happens when a signed integer is shifted right is implementation defined.  \r\n\r\n" + 
"Either zeros are added to the left or ones (to preserve the sign bit) are added to the left.",

// question 14 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"int *p;\r\n\r\n" + 
"is not a null pointer.  p is not initialized to anything so its value is unknown.  The rest " + 
"of the choices are initialized to 0.  ",

// question 15 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"The three components of the IEEE floating-point representation are:\r\n\r\n" + 
"sign \r\n" + 
"exponent \r\n" + 
"mantissa",
],

[
// Quiz 8 ****************** Bitwise Operators & Binary ***************

// question 1 (answer 2) checked 
"Answer B: \r\n\r\n" + 
"~    known as the one's complement operator or bitwise NOT operator",

// question 2 (answer 4) checked 
"Answer D: \r\n\r\n" + 
"|   known as the bitwise inclusive OR operator",

// question 3 (answer 1) checked
"Answer A: \r\n\r\n" + 
"for a negative value, two's complement takes the one's complement of the positive binary " + 
"representation of the value and adds 1.\r\n\r\n" + 
"2 \r\n" + 
"0000 0000 0000 0010  \r\n\r\n" + 
"one's complement of 2 \r\n" + 
"1111 1111 1111 1101 \r\n\r\n" + 
"add one\r\n" + 
"1111 1111 1111 1110",

// question 4 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"8 \r\n" + 
"0000 1000 \r\n\r\n" + 
"one's complement of 8\r\n" + 
"1111 0111",

// question 5 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"y = 694    10 1011 0110 \r\n\r\n" + 
"the preprocessor expands BYTE(y) as: \r\n\r\n" + 
"((694) >> (8)) \r\n\r\n" + 
"the right shift operator is used and 694 is shifted 8 places\r\n\r\n" + 
"resulting in 10 (2 in decimal)",

// question 6 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"x |= 2;\r\n\r\n" + 
"This uses the compound assignment operator. It is the bitwise OR assignment operator.  It tests " + 
"each bit.  The result has a bit set if that bit is set in one of both of the operands.  \r\n\r\n" + 
"( x is:  01001000  01000000  )  0x4840;\r\n" + 
"( x is:  01001000  01000010  )  x |= 2;" ,

// question 7 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"This uses the bitwise AND assignment operator and the one's complement.  The " + 
"one's complement operation is performed first.\r\n\r\n" + 
"( 01001000  01000010  )  0x4842;\r\n" + 
"( 11111111  11111101  )  ~2\r\n" + 
"( 01001000  01000000  )  result" ,


// question 8 (answer 1) checked 
"Answer A: \r\n\r\n" + 
"if(x & 2)  \r\n\r\n" + 
"( 01001000  01000010  )  0x4842;\r\n" + 
"( 00000000  00000010  )  AND operation \r\n" + 
"( 00000000  00000010  )  result \r\n\r\n" + 
"The result is 2 which evaluates true. ",

// question 9 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"~0  \r\n\r\n" + 
"0000 0000 \r\n" + 
"1111 1111 (~0)\r\n\r\n" + 
"1111 1111 is equivalent to  255 for an unsigned char",

// question 10 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"The result of the bitwise inclusive OR on RED and BLUE is 101 (decimal 5)\r\n\r\n" + 
"x is then initialized with 5.",

// question 11 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"x &= ~BLUE; \r\n\r\n" + 
"x is now 2",

// question 12 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"x = x & ~14 | 10 \r\n\r\n" + 
"sets the bitfield",

// question 13 (answer 1) checked 
"Answer A: \r\n\r\n" + 
"x << 4 >> 8; \r\n" + 
"the bitwise shift operators are left associative. \r\n\r\n" + 
"1101 0000 1000 1011  left shift 4 \r\n" + 
"0000 1000 1011 0000  right shift 8 \r\n" + 
"0000 0000 0000 1000",

// question 14 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"~0xF is: \r\n\r\n" + 
"0xF is hex equal to: \r\n" + 
"0000 1111 \r\n\r\n" + 
"1111 0000  is ~0xF",

// question 15 (answer 1) checked
"Answer A: \r\n\r\n" + 
"0xFF is hex equal to: \r\n\r\n" + 
"1111 1111 \r\n\r\n" + 
"or 255 in decimal",
],

[
// Quiz 9 ****************** Preprocessor *****************************

// question 1 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"Resolving external references is done by the linker.", 

// question 2 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"macro is not a keyword.  A #define directive may create a macro.  \r\n\r\n" + 
"#, ##, and defined are preprocessor operators.",

// question 3 (answer 4) checked 
"Answer D: \r\n\r\n" + 

"The ## operator merges two tokens.",

// question 4 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"include <stdio.h>\r\n\r\n" + 
"is illegal.  A preprocessor directive must begin with #.",

// question 5 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"M(a, b) is expanded into:\r\n\r\n" + 

"((a) < (b) ? (a) : (b))\r\n\r\n" + 

"The ?: is the conditional operator.  It is the only ternary operator.  " + 
"It has 3 operands. \r\n\r\n" + 

"(a) < (b)   evaluates true, so the result is the second operand after evaluation.  " + 
"a is passed to printf with the value 2.",

// question 6 (answer 2) checked ( ternary operator ? : has sequence points )
"Answer B: \r\n\r\n" + 

"M(++a, b) is expanded into:\r\n\r\n" + 

"((++a) < (b) ? (++a) : (b))\r\n\r\n" + 

"The ?: is the conditional operator.  It is the only ternary operator.  " + 
"It has 3 operands. \r\n\r\n" + 

"(++a) < (b)   evaluates true, so the result is the second operand after evaluation.  " + 
"a is incremented twice during evaluation.  First in the first operand and again in the " + 
"second operand.  When a is passed to printf, it is 4. ",

// question 7 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"PTR_INT a, b, c;  expands into:\r\n\r\n" + 

"int * a, b, c;\r\n\r\n" + 
"which declares one pointer to an int and 2 type int variables. ",

// question 8 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"The standard requires a few macros to be predefined by the implementation.  \r\n\r\n" + 
"__END__ is not one of them.  The predefined macros are: \r\n\r\n" + 
"__LINE__ \r\n" + 
"__FILE__ \r\n" + 
"__DATE__ \r\n" + 
"__TIME__ \r\n" + 
"__STDC__ ",

// question 9 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The preprocessor operator # performs stringization.  It turns its operand into a string " + 
"literal. ",

// question 10 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"#ifndef DEBUG  \r\n\r\n" + 
"Since DEBUG is defined, anything between this line and the matching #endif is " + 
"conditioned out. ",

// question 11 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"PR_INT(a / 2);   is expanded into: \r\n\r\n" + 

"printf( \"a / 2\" \" = %d\", a / 2 ) \r\n\r\n" + 

"The argument to PR_INT is stringized:\r\n" + 
"\"a / 2\" .\r\n\r\n" + 
"Then \"a / 2\" and \" = %d\" are concatenated to form the printf format " + 
"string: \r\n\r\n" + 
"\"a / 2 = %d\"",

// question 12 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"XTEN(2 + 4) is expanded to: \r\n\r\n" + 
"(2 + 4 * 10) \r\n\r\n" + 
"resulting in 42, not the likely meant result of 60.  \r\n\r\n" + 
"To prevent errors like this, " + 
"parentheses can be put around each parameter in a macro replacement list.",

// question 13 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"y is 4.84 \r\n\r\n" + 

"after macro expansion: \r\n\r\n" + 
"double y = 6.6 / 3 * 2.2 ;\r\n\r\n" + 
"resulting in 4.84, not the likely meant result of 1.\r\n\r\n" + 
"To prevent errors like this, " + 
"parentheses can be put around the macro replacement list. This is necessary if the " + 
"replacement list includes an operator.",

// question 14 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"#    on a line as the only non-whitespace character is a null preprocessor directive.",

// question 15 (answer 3) checked
"Answer C: \r\n\r\n" + 

"defined is a preprocessor operator, not a directive.",
],

[
// Quiz 10 ****************** Compiler and Linker *********************

// question 1 (answer 2) checked 
"Answer B:  \r\n\r\n" + 

"A linker resolves references between translation units.  To resolve external references to " + 
"functions and objects that are not defined in the current translation, " + 
"library components are linked.",

// question 2 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"A translation unit is a source file after includes and conditional compilation.",

// question 3 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"There are eight phases of translation defined in the standard.  However, the names of the " + 
"phases in these lists are not used in the standard.  They are used here to give a general " + 
"description of each category. \r\n\r\n" + 

"The eight phases of translation can be categorized as: \r\n\r\n" + 

"Character Mapping\r\n" + 
"Line Splicing\r\n" + 
"Tokenization\r\n" + 
"Preprocessing\r\n" + 
"Character-set mapping\r\n" + 
"String concatenation\r\n" + 
"Translation\r\n" + 
"Linkage",

// question 4 (answer 2) checked p. 116 ref
"Answer B: \r\n\r\n" + 


"Though it is not required by the standard, traditionally when there is a declaration with " + 
"external linkage that is never referenced a compiler takes this into account. " + 
"The compiler notices that it isn't referenced and doesn't pass the external reference " + 
"to the linker.  Thus, a function that is never used is not loaded to take up space " + 
"unnecessarily. For example with the declaration:\r\n\r\n" + 
"extern int f(void); \r\n\r\n" + 
"If there is no reference to f, then the compiler doesn't include f in " + 
"the table that it gives to the linker to resolve external references.",

// question 5 (answer 1) checked 
"Answer A: \r\n\r\n" + 

"main( ) \r\n" + 
	"{ \r\n" + 
	"       int x; \r\n" + 
	"}\r\n\r\n" + 
"x is declared with automatic storage duration. Storage for variables with automatic " + 
"storage duration is allocated on the stack.  The declarations B, C, D all have static " + 
"storage duration.  This storage is allocated on the heap. ",

// question 6 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"A.   This is a function declaration (prototype form) that has external linkage.  It refers " + 
"to a function definition elsewhere. \r\n\r\n" + 

"B.   x is declared in a function with no storage class specifier.  This gives x automatic " + 
"storage duration which " + 
"means space is allocated on the stack when storage for x is reserved. \r\n\r\n" + 

"C.   x is declared outside of any function without any storage class specifier.  This gives x " + 
"static storage duration which is allocated on the heap at load-time. \r\n\r\n" + 

"D.   x is declared with the extern storage class specifier without an initializer.  This gives " + 
"x external linkage and must be defined elsewhere if it is to be referenced.  ",

// question 7 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"When a compiler is parsing an input stream into tokens, it creates the " + 
"longest token possible from left to right.  Thus, the expression: \r\n\r\n" + 
"x+++y \r\n\r\n" + 
"is parsed as  x++  +  y instead of x  +  ++y.",

// question 8 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"The expression x+++y is an argument.  It is parsed as x++ + y.  \r\n\r\n" + 
"This evaluates to 10.  " + 
"The increment is postfix so the value of the expression x++ is 5.  Then that 5 is added " + 
"to y (5).",

// question 9 (answer 4) checked
"Answer D: \r\n\r\n" + 

"This is a syntax error.  \r\n\r\n" + 
"When a compiler is parsing an input stream into tokens, it creates the " + 
"longest token possible from left to right.\r\n\r\n" + 
"x+++++y   \r\n\r\n" + 
"is parsed as x++  ++  +y  \r\n\r\n" + 
"The increment operator (++) needs an lvalue. ",

// question 10 (answer 4) checked
"Answer D: \r\n\r\n" + 

"+ ++i \r\n\r\n" + 
"is legal.  The increment operator is applied to i then the unary plus operator is applied to " + 
"i resulting in the same value as its operand, i.",

// question 11 (answer 2) checked
"Answer B: \r\n\r\n" + 

"Adjacent string literals are concatenated in translation phase 6 after preprocessing " + 
"directives are executed in translation phase 4.",

// question 12 (answer 3) checked 
"Answer C: \r\n\r\n" + 

"Whether type char is signed or unsigned is implementation-defined behavior.  " + 
"This is documented in the <limits.h> header file.\r\n\r\n" + 

"The standard defines four types of behavior as follows:  \r\n\r\n" + 

"unspecified behavior:  behavior where the standard gives 2 or more possibilities but does " + 
"not require which is to be used or if the choice is to be documented.\r\n\r\n" + 

"undefined behavior:  behavior where the standard doesn't give possibilities or requirements " + 
"or require documentation.\r\n\r\n" + 

"Implementation-defined behavior:  behavior that the standard leaves to the implementation " + 
"to determine.  The behavior must be documented.\r\n\r\n" + 

"Locale-specific behavior:  behavior that depends on a nationality, culture, or language " + 
"that is documented by an implementation.",

// question 13 (answer 2) checked 
"Answer B: \r\n\r\n" + 

"Signed integer overflow is undefined behavior. \r\n\r\n" + 

"The standard defines four types of behavior as follows:  \r\n\r\n" + 

"unspecified behavior:  behavior where the standard gives 2 or more possibilities but does " + 
"not require which is to be used or if the choice is to be documented.\r\n\r\n" + 

"undefined behavior:  behavior where the standard doesn't give possibilities or requirements " + 
"or require documentation.\r\n\r\n" + 

"Implementation-defined behavior:  behavior that the standard leaves to the implementation " + 
"to determine.  The behavior must be documented.\r\n\r\n" + 

"Locale-specific behavior:  behavior that depends on a nationality, culture, or language " + 
"that is documented by an implementation.",

// question 14 (answer 1) checked - page 62
"Answer A: \r\n\r\n" + 

"The order in which the arguments to a function are evaluated is unspecified behavior. \r\n\r\n" + 

"The standard defines four types of behavior as follows:  \r\n\r\n" + 

"unspecified behavior:  behavior where the standard gives 2 or more possibilities but does " + 
"not require which is to be used or if the choice is to be documented.\r\n\r\n" + 

"undefined behavior:  behavior where the standard doesn't give possibilities or requirements " + 
"or require documentation.\r\n\r\n" + 

"Implementation-defined behavior:  behavior that the standard leaves to the implementation " + 
"to determine.  The behavior must be documented.\r\n\r\n" + 

"Locale-specific behavior:  behavior that depends on a nationality, culture, or language " + 
"that is documented by an implementation.",

// question 15  (answer 2) checked - undefined p.77 footnote standard
"Answer B: \r\n\r\n" + 

"Dereferencing a pointer that hasn't been initialized is undefined behavior.\r\n\r\n" + 

"The standard defines four types of behavior as follows:  \r\n\r\n" + 

"unspecified behavior:  behavior where the standard gives 2 or more possibilities but does " + 

"not require which is to be used or if the choice is to be documented.\r\n\r\n" + 

"undefined behavior:  behavior where the standard doesn't give possibilities or requirements " + 
"or require documentation.\r\n\r\n" + 

"Implementation-defined behavior:  behavior that the standard leaves to the implementation " + 
"to determine.  The behavior must be documented.\r\n\r\n" + 

"Locale-specific behavior:  behavior that depends on a nationality, culture, or language " + 
"that is documented by an implementation.",
]

];

/****************************************************************************************************/



function loadQuiz()
{	
	qNum.innerText = currQuestion + ".";
	question.innerText = quizzes[currQuiz - 1][currQuestion - 1][0];
	a.innerText = quizzes[currQuiz - 1][currQuestion - 1][1];
	b.innerText = quizzes[currQuiz - 1][currQuestion - 1][2]; 
	c.innerText = quizzes[currQuiz - 1][currQuestion - 1][3];
	d.innerText = quizzes[currQuiz - 1][currQuestion - 1][4];	
}


function checkAnswer()
{		
	var btn;
	
	if(Radio1.checked == true)
	{
		btn = 1;
	}
	else if(Radio2.checked == true)
	{
		btn = 2;
	}
	else if(Radio3.checked == true)
	{
		btn = 3;
	}
	else
	{
		btn = 4;
	}
	
	if(correctAnswer[((currQuiz - 1) * 15) + currQuestion - 1] == btn)
	{
		
		score++;
		scoreTD.innerText = "Score: " + score;
		Correct();
		
		// alert("Correct");
	}
	else
	{
		Incorrect();
		// alert("Incorrect");
	}
	
	txtareaRev.style.visibility = "visible";
	txtareaRev.innerText = rev[currQuiz - 1][currQuestion - 1];
	
	if(correctAnswer[((currQuiz - 1) * 15) + currQuestion - 1] == 1)
		a.style.backgroundColor = "#E6E6FA";
	else if(correctAnswer[((currQuiz - 1) * 15) + currQuestion - 1] == 2)
		b.style.backgroundColor = "#E6E6FA";
	else if(correctAnswer[((currQuiz - 1) * 15) + currQuestion - 1] == 3)
		c.style.backgroundColor = "#E6E6FA";
	else 
		d.style.backgroundColor = "#E6E6FA";
	
	answer.disabled = true;
	
	Radio1.disabled = true;
	Radio2.disabled = true;
	Radio3.disabled = true;
	Radio4.disabled = true;
	
	if(currQuestion == 15)
	{   
		alert("thanks for testing.\nYour score is: " + score);
		return;
	}
	
	// after the currQuestion check so it's not enabled
	next.disabled = false;
	currQuestion++;
}
	
function nextQuestion()
{
	answerTD.style.backgroundColor = "";
	answerTD.innerText = " ";
	
	a.style.backgroundColor = "";
	b.style.backgroundColor = "";
	c.style.backgroundColor = "";
	d.style.backgroundColor = "";
	
	clearRadio();
		
	questionTD.innerText = "Question   " + (currQuestion < 10 ? " " + currQuestion : currQuestion) + 
	" / 15";
	
	loadQuiz();	
	
	next.disabled = true;
	
	Radio1.disabled = false;
	Radio2.disabled = false;
	Radio3.disabled = false;
	Radio4.disabled = false;
	
	txtareaRev.style.visibility = "hidden";
}

/* ******************** event handlers ********************************/

function radioClicked()
{	
	answer.disabled = false;
}


function Correct()
{
	answerTD.innerText = 'Correct';
	answerTD.style.backgroundColor = "green";
	
	//answerTD.style.borderWidth = 5;
	answerTD.style.color = "white"
	//answerTD.style.fontSize = "100%"
	//answerTD.style.borderColor = "green"
}
function Incorrect()
{
	answerTD.style.color = "white"
	answerTD.innerText = 'Incorrect';
	answerTD.style.backgroundColor = "maroon";
}

function selQuizChanged()
{
	var bConfirm = true;
	
	if(currQuestion != 15)
	{
		var bConfirm = confirm("Do you want do end the quiz and start quiz " + 
			(selQuiz.selectedIndex + 1) + "?");
	}
	
	if(bConfirm)
	{
		currQuiz = selQuiz.selectedIndex + 1;
		currQuestion = 1;
		score = 0;
		
		nextQuestion();	
	}
	else
	{
		selQuiz.selectedIndex = currQuiz - 1;
	}
}

function clearRadio()
{
	if(Radio1.checked == true)
		Radio1.checked = false;
	else if(Radio2.checked == true)
		Radio2.checked = false;
	else if(Radio3.checked == true)
		Radio3.checked = false;
	else
		Radio4.checked = false;
}

