# sol1 - 1.124J Foundations of Software Engineering Problem...

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

1.124J Foundations of Software Engineering Problem Set 1- Solution Due Date: Tuesday 9/19/00 Problem 1:[15%] Questions 1-3: Consider the following code: #include <iostream.h> extern int x; // Statement a int main() { int a, b; // Statement b double d = 9; // Statement c a = 1; // Statement d b = 5; // Statement e cout << x+ a/b + d/10 << endl; } 1. Which line of the above code is both a definition and an initialization? -> C 2. Which line of the above code declares a variable without allocating memory for it? -> a 3. Which lines of the above code are assignments? -> d & e 4. According to the following statement: const *int p; b. the value of the integer that p points to cannot change

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

View Full Document
5. When the following logical test is true? ( x>=y && ! x && x* y < 0 && y==0) e. never 6. Which of the following cases of mixed expressions is/are correct (circle the correct one(s)), considering the following definition: double d; float f; int i; char c; c. ’f’ - ’d’ is an int 7. What is the result of the statement following the definitions given below? char c='b'; char *pc=&c; char *&rc=pc ; (*rc)++; c. it increases *rc 8. Considering the following definitions, which of the provided statements (if any) are invalid? double x= 0.5, y=4.9; double *px, *py, &rx=x; a. px =&x; double &rx = *px ; d. px = px = rx; e. px = py = *x; 9. Considering the following definitions, which of the provided statements (if any), would give the value of x , assuming that x is a double that has been properly defined and initialized to a value? void *pp = &x;
double *px=&x; double **ppx=&px; a. **ppx b. *(static_cast <double*>(pp)) d. *(*(&px)) e. *( (double*)pp) 10. Which of the following expressions give(s) as result an int equal to 6? a. ’z’ - ’t’ b. 13 % 7 e. 55 % 7 11. What will be the value of x after the execution of the following line? int x = (7>6 ? 1+8 : 8) e. 9 12. Which of the following is a valid function declaration (i.e. prototype)? a. void func(int x);

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 ]}

### Page1 / 15

sol1 - 1.124J Foundations of Software Engineering Problem...

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

View Full Document
Ask a homework question - tutors are online