ANSWERS TO QUIZ 1 --------------------- Question 1 ---------- The difference is that one of the variable is defined type "extern". extern exposes variables in one implementation file to a different implementation file and hence can be considered as a global declaration of the variable. Question 2 ---------- a. valid b. valid c. invalid : correct declaration : string Namespace; d. invalid : correct declaration : string catch_22; e. invalid : correct declaration : char one_or_2; f. valid Question 3 --------- pi is a null pointer and in foobar you are trying to dereference a null pointer which is an invalid operation. simple fix : int foobar(int *pi) { if(pi != 0) { *pi = 1024; return (*pi); } return -1; // you can return anything you want } Question 4 ------------ You are returning the address of a stack allocated variable (b). After function foo returns, the memory for b is deallocated from the stack, hence you are actually returning the address of something which does not exist in memory. Question 5 ---------- One of the several right answers int *sort(int *array, int n) { for(int i=0;i array[j]) { swap(&array[i],&array[j]); } } } return array; } void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } Question 6 ---------- One of the many right answers. #include using namespace std; int main() { const int MAX = 255; char line[MAX]; int a_cnt= 0, e_cnt = 0, i_cnt = 0, o_cnt = 0, u_cnt = 0; memset(line,0,MAX); cin.getline(line, MAX); for(int i=0;i