CS 1044 Programming in C++ Test 1 Spring 2011 Form B Page 1 of 12 READ THIS NOW!
|
|
- Camilla Letitia Gibson
- 6 years ago
- Views:
Transcription
1 Spring 2011 Form B Page 1 of 12 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print your name & address in the spaces provided below. Print your name and Va Tech ID number (NOT your SSN) on the Opscan form; be sure to code your ID number on the Opscan form. Code Form B on the Opscan. Choose the single best answer for each question some answers may be partially correct. If you mark more than one answer, it will be counted wrong. Unless a question involves determining whether given C++ code is syntactically correct, assume that it is. The given code has been compiled and tested, except where there are deliberate errors. Unless a question specifically deals with compiler #include directives, you should assume the necessary header files have been included. Note that questions about printed values disregard formatting completely. In questions/answers which require a distinction between integer and real values, integers will be represented without a decimal point, whereas real values will have a decimal point, [ 1044 (integer), (real)]. When you have finished, sign the pledge at the bottom of this page and turn in the test and your Opscan. This is a closed-book, closed-notes examination. No calculators or other electronic devices may be used during this examination. You may not discuss (in any form: written, verbal or electronic) the content of this examination with any student who has not taken it. You must return this test form when you complete the examination. Failure to adhere to any of these restrictions is an Honor Code violation. Mark your answers on the test form, for future reference, and on the Opscan. The answers you mark on the Opscan form will be considered your official answers. There are 35 multiple-choice questions. Do not start the test until instructed to do so! Name VT (print: Last name, (print: campus address) Pledge: On my honor, I have neither given nor received unauthorized aid on this examination. signature
2 Fall 2011 Form B Page 2 of 12 For the next eight questions, consider writing a program that is to read data records consisting of: The name of a computer processor unit (CPU), followed immediately by a tab, then The model of the processor, followed immediately by a tab, then A double representing the giga-hertz clock cycle, followed immediately by a tab, then An integer representing the PaasMark benchmark score, followed immediately by a newline. The name of the input is file, "cpus.txt", the first two lines contains labels. An incomplete example follows: #Computer processor benchmark results #name model speed-ghz PassMark Intel Core i7 995X Intel Xeon W Intel Core i7 2600K AMD Opteron 6176SE AMD Six-Core xxxx Assume that the necessary header files have been included in the program. The program below must read through the data lines and compute the average CPU speed and PassMark score. CPUs with a speed of 0.0 have an unknown speed and must not be computed in the CPU speed average. Consider the following partial implementation of code to solve this problem: int main() { int numcpus = 0, speedcount = 0, passscore, totalpassmarks = 0; double speed, avgspeed, avgpassmark, sumspeeds = 0.0; ifstream ifile; ifile.open("cpus.txt"); // Input the first data line // Task 0: skip the first two label lines // Task 1: skip the processor name while ( ifile ) { // Task 2: skip the processor model // Task 3: input the processor speed // Task 4: input the processor pass mark score // Task 5: update the count of the number of CPUs input // Task 6: update the speed count of CPUs with positive speeds // Task 7: keep a running subtotal of the CPU speeds // Task 8: keep a running subtotal of the CPU pass mark scores // Task 9: skip to the next input dataline // Task 10: skip the processor name }//endwhile ifile.clear(); if ( numcpus > 0 ) // Task 11: compute the average pass mark score // Task 12: output the average pass mark score if (speedcount > 0 ) // Task 13: compute the average CPU speed in GHz // Task 14: output the average CPU speed (GHz) } return EXIT_SUCCESS;
3 Fall 2011 Form B Page 3 of 12
4 Fall 2011 Form B Page 4 of 12 1) Which of the following code fragments will properly carry out Task 1, (skip the processor name)? 1) ifile << speed; 2) ifile >> speed; 3) getline(ifile, speed); 4) getline(ifile, speed, '\t'); 5) ifile.ignore( 20, \t ); 6) 1 and 3 only 7) 2 and 3 only 8) 1 and 4 only 9) 2 and 4 only 10) None of these 2) Assuming correct solutions to the tasks 1-2, which of the following code fragments will then properly carry out Task 3, (input the processor speed)? 1) ifile << speed; 2) ifile >> speed; 3) getline(ifile, speed); 4) getline(ifile, speed, '\t'); 5) ifile >> speed >> '.' >> speed; 6) 1 and 3 only 7) 2 and 3 only 8) 1 and 4 only 9) 2 and 4 only 10) None of these 3) Assuming correct solutions to the tasks 1-4, which of the following code fragments will then properly carry out Task 5, (update the count of the number of CPUs input)? 1) numcpus++; 2) --numcpus; 3) numcpus = numcpus + speed 4) numcpus = speed + 1; 5) 1 and 3 only 6) 3 and 4 only 7) All of these 8) None of these 4) Assuming correct solutions to tasks 1-5, which of the following code fragments will then properly carry out Task 6, (update the speed count of CPUs with positive speeds)? 1) ++speedcount; 2) if (speed > 0.0) speedcount++; 3) if (passscore > 0) speedcount++; 4) if (numcpus > 0) speedcount++; 5) All of these 6) 1 and 3 only 7) 2 and 3 only 8) 1 and 4 only 9) None of these
5 Fall 2011 Form B Page 5 of 12 5) Assuming correct solutions to tasks 1-6, which of the following code fragments will then properly carry out Task 7, (keep a running subtotal of the CPU speeds)? 1) sumspeeds = speed; 2) sumspeeds++; 3) sumspeeds = sumspeeds + speed; 4) speed = speed + sumspeeds; 5) All of these 6) 1 and 2 only 7) 1 and 4 only 8) 2 and 3 only 9) None of these 6) Assuming correct solutions to tasks 1-7, which of the following code fragments will then properly carry out Task 8, (keep a running subtotal of the CPU pass mark scores)? 1) totalpassmarks++; 2) totalpassmarks = passscore; 3) passscore = totalpassmarks + passscore; 4) totalpassmarks = totalpassmarks + passscore; 5) passscore++; 6) passscore = totalpassmarks; 7) 1 and 3 only 8) 2 and 4 only 9) 3 and 5 only 10) None of these 7) Assuming correct solutions to tasks 1-10, which of the following code fragments will then properly carry out Task 11, (compute the average pass mark score)? Hint: select the best answer. 1) avgpassmark = passscore / numcpus; 2) avgpassmark = passscore / totalpassmarks; 3) avgpassmark = passscore / double(totalpassmarks); 4) avgpassmark = totalpassmarks / numcpus; 5) avgpassmark = totalpassmarks / double(numcpus); 6) avgpassmark = totalpassmarks / double(passscore); 7) 1 and 3 only 8) 2 and 4 only 9) 3 and 5 only 10) None of these
6 Fall 2011 Form B Page 6 of 12 8) Assuming correct solutions to tasks 1-12, which of the following code fragments will then properly carry out Task 13, (compute the average CPU speed in GHz)? 1) avgspeed = speed / speedcount; 2) avgspeed = sumspeeds / speedcount; 3) avgspeed = speed / numcpus; 4) avgspeed = sumspeeds / numcpus; 5) avgspeed = avgspeed / numcpus; 6) avgspeed = avgspeed / speedcount; 7) 1 and 3 only 8) 2 and 4 only 9) 3 and 5 only 10) None of these 9) What output would the following code fragment produce? int Value = 42; cout << " " << endl; cout << setw(10) << setfill(' ') << Value << setw(10) << setfill('.') << Value; 1) ) ) ) ) None of these 10) What output would the following code fragment produce? int TotalInCents = 4209; int Dollars = TotalInCents / 100; int Cents = TotalInCents % 100; cout << " " << endl; cout << setw(7) << setfill(' ') << Dollars << setw(2) << setfill('0') << Cents; 1) ) ) ) ) None of these
7 Spring 2011 Form B Page 7 of 12 Consider the following simple polynomial: f(x) = 3x 3 + 2x 2 + x Given the following C++ variable declarations: double fn, //the function of x x; 11) Assume that x has been assigned a value. Which one of the following lines of code accurately assigns the fn to the correct computation of the above polynomial? 1) fn = 3x^3 + 2x^2 + x; 2) fn = 3*x^3 + 2*x^2 + x; 3) fn = 3*x**3 + 2*x**2 + 1*x**x; 4) fn = x * ( x * ( 3 * x + 2 ) + 1 ); 5) None of the above For the following 5 questions, suppose the (file) input stream infile contains the following 5 lines of data (there's several blank characters between columns and a newline character immediately after the last character on each line): Oct Sky Rocket Boys Hickam What is the value of each of the indicated variables after the execution of the following program segment? int zero = 0, one = 1, two = 2, three = 3, four =4; infile >> zero >> zero; infile.ignore(100, '\n'); infile.ignore(100, '\n'); infile >> one >> two >> three >> four; infile.ignore(100, '\n'); infile >> three >> three >> three >> three; infile.ignore(100, '\n'); if (infile) infile >> four; ) zero none of the above 13) one none of the above 14) two none of the above 15) three none of the above 16) four none of the above
8 Spring 2011 Form B Page 8 of 12 17) Give the output that would be produced by the following C++ code: int x = 1; int y = 2; if ( x / y == x ) if ( x % y == x) cout << x; else cout << y; 1) 1 2) 2 3) no output For each of the following 6 questions, assume the following C++ declarations and assignments: int a = 2, b = 5, c = 8, d = 12, e = 23, f = 28; double g = 2.4, h = 5.0; 18) Which of the following expressions would result in the output of the value: 4 1) cout << f / e - b ; 2) cout << c % a ; 3) cout << b / a * a ; 4) cout << c - d + b ; 19) Which of the following expressions would result in the output of the value: 27 1) cout << c + a b * b ; 2) cout << f e + d / a ; 3) cout << c - a + b / b ; 4) cout << f + e - d * a ; 20) Which of the following expressions would result in the output of the value: 3 1) cout << a % b ; 2) cout << b % a ; 3) cout << b % e ; 4) cout << e % b ; 21) Which of the following expressions would result in the output of the value: 25 1) cout << b ^ a ; 2) cout << b ** a ; 3) cout << f ^ (a-1) - a; 4) cout << f ** (a-1) - a;
9 Spring 2011 Form B Page 9 of 12 22) Which of the following expressions would result in the output of the value: 2.4 1) cout << d / h ; 2) cout << g - a ; 3) cout << e / h - a; 4) cout << h - g; 23) Which of the following expressions would result in the output of the value: 2.5 1) cout << b / a ; 2) cout << b / a 0.0 ; 3) cout << g + h / 10; 4) cout << d / ; For the next four questions, consider execution of the following code fragment: bool A, B, C, D; // code that assigns values to A, B, C, and D if (!A B ) if (!C && D ) cout << "one" << endl; else if (D) cout << "two" << endl; else cout << "three" << endl; else if (!C &&!D ) cout << "four" << endl; else if (D) cout << "five" << endl; else cout << "six" << endl; 24) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed? A B C D 1) true false true true 2) true true true false 3) true false false true 4) true true false false 5) false false true true 6) false true true false 7) false false false true 8) false true false false 9) None of these
10 Spring 2011 Form B Page 10 of 12 25) What of the following sets of values for A, B, C, and D would cause the string "three" to be printed? A B C D 1) true false true true 2) true true true true 3) true false false true 4) true true false false 5) false false true true 6) false true true false 7) false false false true 8) false true false false 9) None of these 26) What of the following sets of values for A, B, C, and D would cause the string "four" to be printed? A B C D 1) true false true true 2) true true true true 3) true false false true 4) true true false false 5) false false true true 6) false true true false 7) false false false true 8) true false false false 9) None of these 27) What of the following sets of values for A, B, C, and D would cause the string "six" to be printed? A B C D 1) true false true false 2) true true true true 3) true false false true 4) true true false false 5) false false true true 6) false true true false 7) false false false true 8) true false false false 9) None of these 28) Where will the cpp file be located for a C++ program executed under MS Visual C++ Express by default? 1) the project folder 2)the project folder name under the project folder 3) the debug folder under the project folder 4) the debug folder under the project folder under the project folder
11 Spring 2011 Form B Page 11 of 12 29) Which of the following types of MS Visual C++ Express projects are used in this course? 1) 2) 3) 4) 30) Which of the following is NOT a category of programming errors? 1) Syntax 2) Compilation 3) Linking 4) Execution 5) Runtime 6) All of the above are categories of programming errors. For the next two questions, assume that the input file Data.txt is: 31) What output would the following code fragment produce? ifstream In; In.open("Data.txt"); char Value; In.ignore(12, '\n'); In >> Value; cout << "Value: " << Value << endl; 1) Value: 1 2) Value: 2 3) Value: 3 4) Value: 4 5) Value: 5 6) Value: 6 7) Value: 7 8) Value: 8 9) Value: 9 10) Value: 0 32) What output would the following code fragment produce? ifstream In; In.open("Data.txt"); char Value; In.ignore(2323, '9'); In >> Value; cout << "Value: " << Value << endl; 1) Value: 1 2) Value: 2 3) Value: 3 4) Value: 4 5) Value: 5 6) Value: 6 7) Value: 7 8) Value: 8 9) Value: 9 10) Value: 0
12 Spring 2011 Form B Page 12 of 12 33) An output file that does not contain all of the data written to it by an associated C++ ofstream after the program has completed execution is usually the result of which of the following? 1) The ofstream NOT being opened. 2) The ofstream NOT being closed. 3) The ofstream NOT having showpoint and fixed inserted into it. 4) none of the above For the next two questions select from the following responses: 1) syntax/compilation 2) linking 3) execution / runtime 4) logic 34) Which of the types of programming errors is the responsibility of the programmer to detect? 35) Which of the types of programming errors is due to a violation of the grammar of the language?
CS 1044 Programming in C++ Test 1 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties.
READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Print your name in the space provided below. Print your name and ID number on the Opscan form and code your
More informationREAD THIS NOW! Do not start the test until instructed to do so!
READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print your name in the space
More informationREAD THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Do not start the test until instructed to do so!
READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Print your name in the space provided below. Print your name and ID number on the Opscan form; be sure to
More informationSpring 2002 Page 1 of 8 READ THIS NOW!
Spring 2002 Page 1 of 8 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense.
More informationDo not start the test until instructed to do so!
Fall 1999 Page 1 of 10 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print
More informationFall 2002 Page 1 of 9 READ THIS NOW!
Fall 2002 Page 1 of 9 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense. Print
More informationDo not start the test until instructed to do so!
CS 1054: Programming in Java Page 1 of 6 Form A READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties Failure to adhere to these directions will not constitute
More informationCS 1704 Intro Data Structures and Software Engineering Test 2 Fall 2001 READ THIS NOW!
READ THIS NOW! Print your name in the space provided below. Code Form A on your Opscan. Check your SSN and Form Encoding! Choose the single best answer for each question some answers may be partially correct.
More informationCPE Summer 2015 Exam I (150 pts) June 18, 2015
Name Closed notes and book. If you have any questions ask them. Write clearly and make sure the case of a letter is clear (where applicable) since C++ is case sensitive. You can assume that there is one
More informationCS 1044 Program 2 Spring 2002
Simple Algebraic Calculations One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program (see the end of this specification),
More informationCS 1044 Project 1 Fall 2011
Simple Arithmetic Calculations, Using Standard Functions One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points B Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points A Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,
More information1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?
Instructions: This homework assignment focuses primarily on some of the basic syntax and semantics of C++. The answers to the following questions can be determined from Chapters 6 and 7 of the lecture
More informationCPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)
Name Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Relational Expression Iteration Counter Count-controlled loop Loop Flow
More informationStreams. Parsing Input Data. Associating a File Stream with a File. Conceptual Model of a Stream. Parsing. Parsing
Input Data 1 Streams 2 Streams Conceptual Model of a Stream Associating a File Stream with a File Basic Stream Input Basic Stream Output Reading Single Characters: get() Skipping and Discarding Characters:
More informationSetting Justification
Setting Justification Formatted I/O 1 Justification - Justification refers to the alignment of data within a horizontal field. - The default justification in output fields is to the right, with padding
More informationThe C++ Language. Output. Input and Output. Another type supplied by C++ Very complex, made up of several simple types.
The C++ Language Input and Output Output! Output is information generated by a program.! Frequently sent the screen or a file.! An output stream is used to send information. Another type supplied by C++
More informationDefinition Matching (10 Points)
Name SOLUTION Closed notes and book. If you have any questions ask them. Write clearly and make sure the case of a letter is clear (where applicable) since C++ is case sensitive. There are no syntax errors
More informationI/O Streams and Standard I/O Devices (cont d.)
Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore how to read data from the standard input device Learn how to use predefined
More informationWeek 3: File I/O and Formatting 3.7 Formatting Output
Week 3: File I/O and Formatting 3.7 Formatting Output Formatting: the way a value is printed: Gaddis: 3.7, 3.8, 5.11 CS 1428 Fall 2014 Jill Seaman spacing decimal points, fractional values, number of digits
More informationcausing a set of statements (the body) to be executed repeatedly. C++ provides three control structures to support iteration (or looping).
1 causing a set of statements (the body) to be executed repeatedly. C++ provides three control structures to support iteration (or looping). Before considering specifics we define some general terms that
More informationCOS 126 General Computer Science Spring Written Exam 1
COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.
More informationWe will exclusively use streams for input and output of data. Intro Programming in C++
C++ Input/Output: Streams The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: 1 istream
More informationEECS 183 Fall 2015 Exam 2 Free Response (134 points)
EECS 183 Fall 2015 Exam 2 Free Response (134 points) Closed Book Closed Notes No Electronic Devices Closed Neighbor Turn off Your Cell Phone, even in your backpack We will confiscate all electronic devices
More informationC++ Input/Output: Streams
C++ Input/Output: Streams Basic I/O 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams:
More informationName Section: M/W T/TH Number Definition Matching (8 Points)
Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationCS 111X - Fall Test 1
CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance on this exam. Signature:
More informationc++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.
Chapter 1 File Extensions: Source code (cpp), Object code (obj), and Executable code (exe). Preprocessor processes directives and produces modified source Compiler takes modified source and produces object
More informationwhat are strings today: strings strings: output strings: declaring and initializing what are strings and why to use them reading: textbook chapter 8
today: strings what are strings what are strings and why to use them reading: textbook chapter 8 a string in C++ is one of a special kind of data type called a class we will talk more about classes in
More informationMultiple Choice Questions (20 questions * 6 points per question = 120 points)
EECS 183 Fall 2014 Exam 2 Closed Book Minimal Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including cell phones, calculators,
More informationCSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.
Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 1 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,
More informationCS 1044 Project 2 Spring 2003
C++ Mathematical Calculations: Falling Bodies Suppose an object is dropped from a point at a known distance above the ground and allowed to fall without any further interference; for example, a skydiver
More informationThe Program Specification:
Reading to Input Failure, Decisions, Functions This programming assignment uses many of the ideas presented in sections 3 through 8 of the course notes, so you are advised to read those notes carefully
More informationCSci 1113 Midterm 1. Name: Student ID:
CSci 1113 Midterm 1 Name: Student ID: Instructions: Please pick and answer any 7 of the 9 problems for a total of 70 points. If you answer more than 7 problems, only the first 7 will be graded. The time
More informationIntro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?
Intro to Programming & C++ Unit 1 Sections 1.1-4 and 2.1-10, 2.12-13, 2.15-17 CS 1428 Spring 2019 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program a set
More informationCS101 PLEDGED SPRING 2001
The following exam is pledged. All answers are to be given on the provided answer sheet. The test is closed book, closed note, and closed calculator. If you believe more than one answer is acceptable,
More informationName Section: M/W T/TH Number Definition Matching (6 Points)
Name Section: M/W T/TH Number Definition Matching (6 Points) 1. (6 pts) Match the words with their definitions. Choose the best definition for each word. Event Counter Iteration Counter Loop Flow of Control
More informationUniversity of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1. Professors: ML Dorf, Elliot Soloway
University of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1 Professors: ML Dorf, Elliot Soloway Wed 9- February- 2011 35 questions * 3 pts each = 105 pts (yes we know there
More informationCS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY
CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 - KEY KEY KEY KEY KEY KEY KEY Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance
More informationProblem Score Max Score 1 Syntax directed translation & type
CMSC430 Spring 2014 Midterm 2 Name Instructions You have 75 minutes for to take this exam. This exam has a total of 100 points. An average of 45 seconds per point. This is a closed book exam. No notes
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationCSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100
CSC 126 FINAL EXAMINATION Spring 2011 Version A Name (Last, First) Your Instructor Question # Total Possible 1. 10 Total Received 2. 15 3. 15 4. 10 5. 10 6. 10 7. 10 8. 20 TOTAL 100 Name: Sp 11 Page 2
More information1. Which of the following best describes the situation after Line 1 has been executed?
Instructions: Submit your answers to these questions to the Curator as OQ3 by the posted due date and time. No late submissions will be accepted. For the next three questions, consider the following short
More informationChapter 3 - Notes Input/Output
Chapter 3 - Notes Input/Output I. I/O Streams and Standard I/O Devices A. I/O Background 1. Stream of Bytes: A sequence of bytes from the source to the destination. 2. 2 Types of Streams: i. Input Stream:
More informationCS 1704 Homework 2 C++ Pointer Basics Fall 2002
Instructions: Opscan forms will be passed out in class on Tuesday, Sept 24. Write your name and code your ID number on the opscan form. Turn in your completed opscan at class on Thursday Sept 26, or at
More informationMultiple Choice Questions (20 questions * 5 points per question = 100 points)
EECS 183 Winter 2014 Exam 1 Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including cell phones, calculators,
More informationCome and join us at WebLyceum
Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad
More informationPart 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)
EECS 183 Fall 2013 Exam 1 Part 1 (80 points) Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationGetting started with C++ (Part 2)
Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output
More informationStarting Out with C++: Early Objects, 9 th ed. (Gaddis, Walters & Muganda) Chapter 2 Introduction to C++ Chapter 2 Test 1 Key
Starting Out with C++ Early Objects 9th Edition Gaddis TEST BANK Full clear download (no formatting errors) at: https://testbankreal.com/download/starting-c-early-objects-9thedition-gaddis-test-bank/ Starting
More informationCS 2604 Minor Project 1 DRAFT Fall 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationwhile for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration)
Week 7: Advanced Loops while Loops in C++ (review) while (expression) may be a compound (a block: {s) Gaddis: 5.7-12 CS 1428 Fall 2015 Jill Seaman 1 for if expression is true, is executed, repeat equivalent
More informationSolution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Summer I Instructions:
VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted
More informationTopic 2. Big C++ by Cay Horstmann Copyright 2018 by John Wiley & Sons. All rights reserved
Topic 2 1. Reading and writing text files 2. Reading text input 3. Writing text output 4. Parsing and formatting strings 5. Command line arguments 6. Random access and binary files Reading Words and Characters
More informationMidterm Examination. Instructor: Gary Chan Date: Saturday, 23 October 2010 Time: 2:30pm 4:00pm Venue: LTC
THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Department of Computer Science & Engineering COMP 152: Object-Oriented Programming and Data Structures Fall 2010 Midterm Examination Instructor: Gary Chan
More informationCSE 131 Introduction to Computer Science Fall Exam I
CSE 131 Introduction to Computer Science Fall 2015 Given: 24 September 2015 Exam I Due: End of session This exam is closed-book, closed-notes, no electronic devices allowed. The exception is the sage page
More informationConsider the following statements. string str1 = "ABCDEFGHIJKLM"; string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is " ". Given the function prototype: float test(int,
More informationFile I/O. File Names and Types. I/O Streams. Stream Extraction and Insertion. A file name should reflect its contents
File I/O 1 File Names and Types A file name should reflect its contents Payroll.dat Students.txt Grades.txt A file s extension indicates the kind of data the file holds.dat,.txt general program input or
More informationInput and Output. Data Processing Course, I. Hrivnacova, IPN Orsay
Input and Output Data Processing Course, I. Hrivnacova, IPN Orsay Output to the Screen Input from the Keyboard IO Headers Output to a File Input from a File Formatting I. Hrivnacova @ Data Processing Course
More informationCSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1]
CSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1] LEARNING OBJECTIVES Upon completion, you should be able to: o define C++ text files o explain the benefits of using I/O file processing o explain
More informationPROGRAMMING EXAMPLE: Checking Account Balance
Programming Example: Checking Account Balance 1 PROGRAMMING EXAMPLE: Checking Account Balance A local bank in your town is looking for someone to write a program that calculates a customer s checking account
More informationCSE143 Exam with answers MIDTERM #1, 1/26/2001 Problem numbering may differ from the test as given.
CSE143 Exam with answers MIDTERM #1, 1/26/2001 Problem numbering may differ from the test as given. All multiple choice questions are equally weighted. You can generally assume that code shown in the questions
More informationCSC 126 FINAL EXAMINATION FINAL Spring 2012 B. Name (last, First) Instructor. Total Possible. Received
CSC 126 FINAL EXAMINATION FINAL Spring 2012 B Name (last, First) Instructor Question # Total Possible Total Received 1. 8 2. 8 3. 8 4. 14 5. 18 6. 10 7. 16 8. 18 TOTAL 100 Final Exam/ Page 2 1) (8 points)
More informationECE264 Fall 2013 Exam 1, September 24, 2013
ECE264 Fall 2013 Exam 1, September 24, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationCS 2505 Computer Organization I
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other computing devices may
More informationStrings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts
Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationCS 2604 Minor Project 1 Summer 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationFor Teacher's Use Only Q No Total Q No Q No
Student Info Student ID: Center: Exam Date: FINALTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Time: 90 min Marks: 58 For Teacher's Use Only Q No. 1 2 3 4 5 6 7 8 Total Marks Q No. 9
More informationLAB: STRUCTURES, ARRAYS,
LAB: STRUCTURES, ARRAYS, AND FILES IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2008-2016 VERSION 3.3 PALMS MODULE 2 LAB: STRUCTURES, ARRAYS, AND FILES IN C++ 2 Introduction This lab
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationCSE 131S Introduction to Computer Science Summer SON Exam I
CSE 131S Introduction to Computer Science Summer SON 2014 Exam I Given: 1 July 2014 Due: End of live session This exam is closed-book, closed-notes, no electronic devices allowed except for downloading
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter Two MULTIPLE CHOICE
Chapter Two MULTIPLE CHOICE 1. In a C++ program, two slash marks ( // ) indicate: a. The end of a statement b. The beginning of a comment c. The end of the program d. The beginning of a block of code 2.
More informationCOS 126 Midterm 1 Written Exam, Fall 2009
NAME: login ID: precept: COS 126 Midterm 1 Written Exam, Fall 2009 This test has 8 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No
More informationReview Questions II KEY
CS 102 / ECE 206 Spring 2011 Review Questions II KEY The following review questions are similar to the kinds of questions you will be expected to answer on Exam II (April 7), which will focus on LCR, chs.
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationLab # 02. Basic Elements of C++ _ Part1
Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationChapter 3: Input/Output
Chapter 3: Input/Output I/O: sequence of bytes (stream of bytes) from source to destination Bytes are usually characters, unless program requires other types of information Stream: sequence of characters
More informationCS 103: Introduction to Programming Fall Written Final Exam 12/11/16, 4:30PM 6:30PM
CS 103: Introduction to Programming Fall 2017 - Written Final Exam 12/11/16, 4:30PM 6:30PM Name: USC Email Address: Lecture (Circle One): Redekopp 2:00 TTh Goodney: 2 MW 9:30 TTh 11:00 TTh Complete the
More informationSoftware Design & Programming I
Software Design & Programming I Starting Out with C++ (From Control Structures through Objects) 7th Edition Written by: Tony Gaddis Pearson - Addison Wesley ISBN: 13-978-0-132-57625-3 Chapter 3 Introduction
More informationCSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:
CSE 131 Introduction to Computer Science Fall 2016 Given: 29 September 2016 Exam I Due: End of Exam Session This exam is closed-book, closed-notes, no electronic devices allowed The exception is the "sage
More informationCS 1044 Program 6 Summer I dimension ??????
Managing a simple array: Validating Array Indices Most interesting programs deal with considerable amounts of data, and must store much, or all, of that data on one time. The simplest effective means for
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationThe American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science
The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science Instructor: Dr. Khalil Final Exam Fall 2012 Last Name :... ID:... First Name:... Form
More informationCSE 131 Introduction to Computer Science Fall Exam I
CSE 131 Introduction to Computer Science Fall 2013 Given: 30 September 2013 Exam I Due: End of session This exam is closed-book, closed-notes, no electronic devices allowed. The exception is the cheat
More informationgcc o driver std=c99 -Wall driver.c bigmesa.c
C Programming Simple Array Processing This assignment consists of two parts. The first part focuses on array read accesses and computational logic. The second part focuses on array read/write access and
More informationWhat we will learn about this week:
What we will learn about this week: Streams Basic file I/O Tools for Stream I/O Manipulators Character I/O Get and Put EOF function Pre-defined character functions Objects 1 I/O Streams as an Introduction
More informationFor questions 4 through 7, select the value assigned to the relevant variable, given the declarations: 3) ) This is not allowed
This homework assignment focuses primarily on some of the basic syntax and semantics of C. The answers to the following questions can be determined by consulting a C language reference and/or writing short
More informationCS201 Latest Solved MCQs
Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability
More informationCOS 126 General Computer Science Spring Written Exam 2
COS 126 General Computer Science Spring 2011 Written Exam 2 This test has 10 questions worth a total of 50 points. You have 50 minutes. The exam is closed book, except that you are allowed to use a one
More informationEngineering Problem Solving with C++, 3e Chapter 2 Test Bank
1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A. integer B 1.427E3 B. double D "Oct" C. character B -63.29 D. string F #Hashtag
More informationThe American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011
The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS
More informationint x = 5; double y = 3; // Integer division rounds the result down to the nearest whole number. cout << "1a: " << x / 3 << endl; //1
PART 1 - From Professor Kent Chin - div_casting.cpp /* Literals are FIXED values (e.g. 0, 5, -2, 3.14) Whole-number literals (e.g. 0, 1, -3) are integer types Literals with decimal points (e.g. 3.14, 2.718)
More informationExam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80
Exam 2 CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson Question Points Score 1 18 2 29 3 18 4 15 Total: 80 I understand that this exam is closed book and closed note and
More information