midterm2_samplequestions

# midterm2_samplequestions - CS201(Intro to Computing MIDTERM...

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

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.

Unformatted text preview: CS201 (Intro. to Computing) MIDTERM II SAMPLE QUESTIONS – Fall 2009 • Those questions do not imply any favorite subject or question type for the questions in the actual exam • Please also review recitation questions, samples covered in the class, homeworks and the questions in the book as well • The amount of questions here is of course much more than the actual exam. QUESTIONS 1) Write a program that solves the following problem: If April 23 rd of a year is a Sunday, what would be the day of week for October 29 th of the same year? Use Date class! 2) a) Write a function that takes a Date parameter and returns the number of days between that date and the last day of that month. b) Write a function that takes a string parameter (call it str ) and returns true if the value of str is “Turkey”, returns false otherwise. All combinations of upper and lowercase letters in “Turkey” are acceptable. For example “TuRKey” or “TUrkeY” (among may other combinations) should also return true. c) What is the output of the following program piece? (December 10, 2002 was a Tuesday) Date day(12,10,2002); Date horrorday = day + 3; string s = horrorday.DayName(); cout << horrorday << " " << s; 3) Write a function that takes a real number as parameter and returns its fractional part. For example, if the parameter is 145.943422, the function should return 0.943422. As another example, if the parameter is -2.4, the function should return 0.4. Write a program that inputs 10 real numbers from keyboard and finds out the real number with the largest fractional part. Your program should display this number. Program should use the above function. Moreover your program should check if the input numbers are real number or not. If a particular input is not a real number, it should be re-entered by the user until a real number is entered. 10 is the number of real numbers! 4) Suppose you have the following function defined in a library bool isTurkish (const string & str); // post: returns true if str is a syntactically correct // Turkish word Write a program that reads a file and displays non-Turkish words of that file on screen. The program should also display the total number of such words. Do not write the isTurkish function body, just use it. In the program, input the file name, open it and check if it is opened successfully or not. 5) In a hypothetical country, May 23 and August 28 are holidays. Moreover, all Saturdays and Sundays are holidays as well. Write a function that takes an integer parameter to represent a year value. This function must return the total number of holiday days in this parameter year....
View Full Document

## This note was uploaded on 03/16/2012 for the course FENS 101 taught by Professor Selçukerdem during the Fall '12 term at Sabancı University.

### Page1 / 9

midterm2_samplequestions - CS201(Intro to Computing MIDTERM...

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

View Full Document
Ask a homework question - tutors are online