10------------------Final06s[1]

10------------------Final06s[1] - Final Exam, PIC 10A,...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 Final Exam, PIC 10A, Spring 2006 Sunday, June 11th 2006 Name: ___________________________________________ Signature: ________________________________________ ID Number: ______________________________________ Discussion Section: _________________________________ Problem 1 2 3 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 5 6 7 8 Total Score h No use may be made of books, notes or electronic devices. h Use only this exam packet and a non-red pen or pencil. h Problems are not necessarily in order of difficulty! Do easy problem first. h If you need more space, make a note and continue on the back of previous page. h If something is unclear to you, raise your hand and I or a TA will come to you
Background image of page 2
Sheet1 Page 3 Problem 1 (20 points) Find the correct answer and circle it from the following choices. 1) Where is a variable declared to make it local to a function? a) in the function prototype b) in the main function c) in the function definition d) before the main ANS: C 2) What operator is used to access a class through a pointer? a) -> b) >> c) * d) & ANS: A a) a positive value b) a negative value 3) What will strcmp(hAstringh, hAstringh) return?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Sheet1 Page 4 c) zero d) true ANS: C 4) Given the code int *p=new int(5) a) the address of a dynamic integer variable b) 5 c) the address of the first index variable of a dynamic array d) int ANS: B 5) Which library you should include if you want to use predefined toupper(char) function? a) #include <iostream> b) #include <fstream> c) #include <string> d) #include <cctype> ANS: D 6) Given the code ifstream fin int onenumber fin >> onenumber fin.open(hinfile.txth)
Background image of page 4
Sheet1 Page 5 Which of the following statement is false? a) fin is declared to be an input stream for a file stream fin to the file named infile.txt s c) read an integer from the file infile.txt into onenumber, if the file contains an integer empty file named infile.txt ANS: D b) produce the same effect, get a new line d) both a) and c) ANS: D 8) Under what circumstances may one use the following syntax for an array a a[] = {1, 2, 3, 4, 5} a) anytime b) when declaring a c) when changing the values of the elements of a d) both (b) and (c) b) if infile.txt does exist, fin.open(hinfile.txth) will connect the input d) if infile.txt doesnht exist, fin.open(hinfile.txth) will create an 7) The difference between h\nh and h\nh is a) h\nh is a value of type char and h\nh is a string c) h\nh is not a char type and cannot be stored in a variable of type char
Background image of page 5

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

View Full DocumentRight Arrow Icon
Sheet1 Page 6 ANS: B 9) What is the output of the following code char ch for(int k = 0 cin >> ch cout << ch If the input is a b c d a) a b c d b) just the return character c) c d) abcd ANS: C 10) Consider the following code int a[10], *p, *q q = p q+=2 what is stored in q a) the value of a[3] b) the address of a[3] c) the value of a[5] d) the address of a[5]
Background image of page 6
Page 7 ANS: D Problem 2 (12 points) what output will be produced by the following code, when embedded in a complete program? a) int a = 5
Background image of page 7

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

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

This note was uploaded on 04/21/2008 for the course PIC 10A taught by Professor Wittman during the Spring '08 term at UCLA.

Page1 / 48

10------------------Final06s[1] - Final Exam, PIC 10A,...

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

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