statistics lecture notes - December 19, 2009 CS201 (Intro....

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

View Full Document Right Arrow Icon
December 19, 2009 CS201 (Intro. to Computing) MIDTERM II 1 2 3 4 5 6 7 TOTAL Name : Solutions ID : Notes: a) Please answer the questions only in the provided space after each question. b) Duration is 100 minutes. c) Closed-book, closed-notes, no calculators and computers. Two A4 size cheat- note pages are allowed. d) There must be seven pages (including this one) in this booklet. Please check it out! QUESTIONS 1) (12 points) In this question you are going to add a new member function to the RandGen class. This member function, named RandChar , will take a string parameter s and return a random character of s . ASSUME that s is NOT empty. a) The header file of the RandGen class should be updated to add this new member function. Which part of the header file should change? Also, write the necessary line(s) that you should add to the header file. The public part of class definition should be updated. The following line must be added there. char RandChar(const string & s); char RandChar(string & s); // also ok char RandChar(string s); // also ok b) Write the implementation of the RandChar member function. char RandGen::RandChar(string s) { int randIndex = RandInt(0, s.length()-1); // or = RandInt(s.length()); return; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
NAME: 2) (12 points) The function below is a partial solution for the following problem: Write a function that takes an input file stream, say thefile , and a character, say thechar , as parameters. The function should return the total number of thechar ’s in thefile . You may assume that thefile has already been successfully opened and its file position pointer is at the beginning. In other words, do not open thefile in the function. For example, if thefile is as below and thechar is ‘p’, then the function returns 4. For the same file, if thechar is ‘z’, then the function returns 0. mini mini bir bug donmustu, laptopuma konmustu. aldim onu iceriye, bir kosede dursun diye
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/23/2011 for the course MATHEMATIC MATH 203 taught by Professor Ulugcapar during the Spring '09 term at Sabancı University.

Page1 / 8

statistics lecture notes - December 19, 2009 CS201 (Intro....

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

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