Foundations of Software Engineering

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

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

View Full Document Right Arrow Icon
1.124J Foundations of Software Engineering Problem Set 1 Due Date: Tuesday 9/19/00 Reference Readings: From C++ Primer: Chapter 1 and Chapter 2 (only skim through) Chapters 3, 4, 5 and 6 Problem 1:[15%] This is a multiple choice question whose purpose is to expose you to several detail issues of C++ programming that are related to a variable definition, data types, mixed expressions, conversions, etc. You need to select the correct answer(s), or provide the answer, as indicated in the following questions. There may be one or more than one correct answers in the multiple choice questions. Please submit this page, stapled together with the hardcopies for the other problems, with the selected answer(s) to each question circled. Please, write your name and username clearly on this page as well. Each question counts for 1 point. 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?
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. Which line of the above code declares a variable without allocating memory for it? 3. Which lines of the above code are assignments? 4. According to the following statement: const int *p; a. the value of the pointer p cannot change b. the value of the integer that p points to cannot change c. both pointer p and the value of the integer that p points tocannot change d. both pointer p and the value of the integer that p points to can change e. p is a constant pointer to int 5. When the following logical test is true? ( x>=y && ! x && x* y < 0 && y==0) a. if x is greater than y, and y is equal to zero b. if both x and y are equal to zero c. if x is positive, and y is equal to zero d. always 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; a. ’f’ - ’d’ is a double b. f / 3.33 is a float c. ’f’ - ’d’ is an int d. ’f’ - ’d’ is a char e. none of the above 7. What is the result of the statement following the definitions given below? char c='b'; char *pc=&c; char *&rc=pc ; (*rc)++;
Background image of page 2
a. it increases b. it stores 'b' in variable c c. it increases *rc d. it increases pc , by one byte e. none of the above 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 ; b. px = py; c. double &ry = rx; 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;
Background image of page 3

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

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

This note was uploaded on 12/04/2011 for the course ESD 1.124 taught by Professor Kevinamaratunga during the Fall '00 term at MIT.

Page1 / 13

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

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