CS1372_Fall_2007_Practice_Final_Answers

CS1372_Fall_2007_Practice_Final_Answers - Problem 1 – C...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Problem 1 – C++ and Fortran A. Circle TRUE or FALSE for the following statements: TRUE FALSE Early versions of FORTRAN required the executable statements to be confined to specific columns TRUE FALSE All FORTRAN versions permit recursion. F77 didn’t TRUE FALSE Strings in FORTRAN are null terminated like C strings. They must have a length specified TRUE FALSE FORTRAN named COMMON blocks and MODULES are equivalent to C structures with the same name TRUE FALSE FORTRAN multi-dimensioned arrays are organized in the same order as C/C++ arrays. The rows and columns are in reverse order TRUE FALSE C++ functions called from FORTRAN must be wrapped in extern “C” { …} B. Which of the following are advantages of Object Oriented Programming I. Cleaner Code II. Code re-use III. Complexity IV. Implementation Independence V. Efficient Execution VI. Lower Maintenance Effort VII. Lower Development Cost VIII. Lower Undetected Error Rate C. Which of the following are language elements specific to C++ (not C)? I. Function overloading (polymorphism) II. Header overloading III. Operator overloading IV. Variable Arguments V. Input and Output Streams VI. Constructors VII. Destructors VIII. Inheritance IX. Defining variables where needed (like for(int i = 0; …) ) CS1372 - Computing for Engineers Practice Final December 6 th , 2007 Page 2 of 9 Problem 2 – Pointers Consider the following code: typedef struct { char *SSN; char studNumber[10]; char *gtID; } Student; A. Fill in the function deep_copy that returns a deep copy of the Student structure: Student *deep_copy(Student *src) { Student *ans = (Student *) malloc( sizeof (Student)); *ans = *src; ans->SSN = strdup(src->SSN); ans->gtID = strdup(src->gtID); return ans; } // deep_copy(Student*) B. Given the following outline, in the space below, write the code to swap any two objects: void generic_swap(void *a, void *b, unsigned int size) { void *temp = malloc(size); memcpy(temp, a, size); memcpy(a, b, size); memcpy(b, temp, size); free(temp); } // generic_swap(void*, void*, uint) C. In the space below, write one line of code that swaps the content of two Student structures: generic_swap( &a, &b, sizeof (Student) ); CS1372 - Computing for Engineers Practice Final December 6 th , 2007 Page 3 of 9 Problem 3 – Program Logic A. Write a recursive version of...
View Full Document

This note was uploaded on 06/17/2008 for the course CS 1372 taught by Professor Smith during the Fall '07 term at Georgia Tech.

Page1 / 9

CS1372_Fall_2007_Practice_Final_Answers - Problem 1 – C...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online