COEN243-Past Exam2001

COEN243-Past Exam2001 - Course Number Section Programming...

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

Course Number Section Programming Methodology I COEN 243 Y, Z Examination Date Time # of pages Final Examination April 23, 2001 3 Hours 5 Instructor (s) Drs. M. Mehmet Ali, M. R. Talla Material allowed : No Yes Calculators allowed : No Yes Special Instructions: Attempt all seven questions. Handwriting should be clear and readable( preferably with pencil). Programs should be well commented. The quality of the programming will also be evaluated. Students should return the question paper after the exam. X X

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

View Full Document
1. Determine the values stored in each of the variables and the addresses held by each of the pointers in the following program, #include <iostream.h> int main ( ) { int x, y, *p, *q, *r; x = 50; q = &y; p = &x; r = q; *r = *p * 2; cout << x << " " << y << endl; return 0; } ( 5 points) 2. Explain the output of the following program ? Determine the type of parameter passing and the return types in each function as call by value, call by reference using reference parameter or call by reference using pointers, explain how you have arrived at the decisions. #include<iostream.h> int amodify ( int, int *); int &bmodify ( int * ); int *cmodify ( int &); int main ( ) { const int asize = 4; int j, a[asize] = {3, 12, 15, 5}; amodify ( a[0], &a[1] ); cout << bmodify ( &a[ 2 ] ) <<endl; cmodify ( a[ 3 ] ); for ( int j = 0; j < asize; j++) cout << a[j] << ", "; cout << endl; return 0; } int amodify ( int x, int *w ) { x = 6; *w = 8; return x; } int &bmodify ( int *z) { int static w; w = *z + 4; return w; } int *cmodify ( int &q) { int static r = 5; r += q; return &r; } ( 7 points)
3. Given an ) * ( m m matrix it will be considered to be symmetric if the elements on the main diagonals are ones and elements off the diagonal are zero. Write a function symmetric that will receive a two-dimensional array and its size as input and determine if the matrix is symmetric as defined in this problem. The function will return true if the function is symmetric and false otherwise. Example: The following matrices are symmetric, = 1 0 1 0 1 0 1 0 1 A = 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 A Note : The solution should be able to handle any size of matrix.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern