{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

mt.s.m09

mt.s.m09 - CS 60 MID-TERM EXAM WRITE ALL YOUR ANSWERS ON...

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 Document Right Arrow Icon

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

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

Unformatted text preview: CS 60 MID-TERM EXAM July 16, 2009 WRITE ALL YOUR ANSWERS ON SPACE PROVIDED. answer ALL questions. Total points are 175. ONLY STUDENTS THAT ARE REGISTERED FOR THIS COURSE MAY TAKE THIS EXAM. NAME: 1 { Circle for each part True or False depending whether or not the statement is true or false. Each question is worth 2 Points } • { True or False } By big-endian we mean that the most significant byte has the lowest address. • { True or False } The function malloc returns a pointer to a block of memory all of which has been initialized to zero. • { True or False } A structure ( struct ) in C may contain inside it another structure ( struct ), but not another structure ( struct ) with a structure ( struc ) inside it. • { True or False } The command mkdir is normally used to create a new directory. • { True or False } The command cd in UNIX is used to play CDs. • { True or False } Linux is the predecessor of Unix. • { True or False } The command copy in Linux is used to copy files. • { True or False } A pointer to a function XX in C can be used to call the function XX in C. • { True or False } The type bool in C does not exist in C++. • { True or False } The command gcc o xxx xxx.C compiles the C++ program stored in file xxx.C and leaves the executable in xxx . • { True or False } In C ( printf ) one uses %d to print the basic type double . • { True or False } A program in C can make a call to main in any of its functions, provided main is defined before all its functions. 1 2 { Simple Questions } a.- [4 points] Suppose that the statement int x = { 6,7,8,9 } is executed in a C++ program. Is x[4] initialized? What is printed when we execute the command cout << *x just after the above statement is executed? No it is not. Prints 6. b.- [4 points] Suppose that just after the statement int *ptr = new int[10] we execute the statements ptr[0] = 3; ptr[1] = 4; ptr[2] = 1; . What is the value of ptr[0] just after the above statements are executed? Now suppose that the statement ptr++; is executed now. Just after this statement is executed, what is the value of ptr[1] ? Value of 3 is printed. the value of ptr[1] is 1. c.- [4 points] For the C++ code given below clearly indicate what cout prints. #include <iostream> using namespace std; int main(void) { int i,s; s = 0; i = 2; for ( int i = 1; i<= 10; i++, s++) { if (s < 4) continue; else break; } cout << i << " " << s << endl; } ANS: 2 4 2 d.- [6 points] For the C++ code given below clearly indicate what cout prints. #include <iostream> using namespace std; class XXX { public: int X(int n=3, int m = 5) {if ( n <= 0 ) return 0; return X(n-1,m)+m; }; }; int main(void) { XXX y; XXX z; cout << y.X() << " " << z.X(4) << " " << z.X(7,y.X(y.X(),z.X(3))) << endl; cout << z.X(y.X(5),y.X(10,2)) << endl; } Ans: 15 20 1575 500 e.- [8 points] In the directory entry-rwxr-xr-- 1 std student 58159 2009-06-28 10:29 temp.txt • Who is the Owner of the file? std • What is the Group of the file? student...
View Full Document

{[ snackBarMessage ]}

Page1 / 19

mt.s.m09 - CS 60 MID-TERM EXAM WRITE ALL YOUR ANSWERS ON...

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

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