|
|
- Donald Ray
- 5 years ago
- Views:
Transcription
1
2
3
4
5
6 Consider 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, int, int); which of the following statements is legal? In C++, the scope resolution operator is. Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num++; executes. A variable listed in a function call is known as a(n) parameter. A variable list in a header is known as a(n) parameter. int alpha = 5; int beta = 10; alpha = alpha + 5; { int alpha = 20; beta = beta + 5 ; } cout << alpha << " " << beta << endl ; What is the output of the following C++ code? int alpha[5] = {2, 4, 6, 8, 10}; int j; for (j = 4; j >= 0; j--) cout << alpha[j] << " "; cout << endl; A loop that continues to execute endlessly is called a(n) loop. What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl; After the execution of the following code, what will be the value of num if the input
7 value is 5? cin >> num; if (num > 0) num = num + 10; else if (num == 5) num = num + 15; Suppose j, sum, and num are int variables, and the input is What is the output of the code? sum = 0; cin >> num; for (int j = 1; j <= 4; j++) { sum = sum + num; cin >> num; } cout << sum << endl; Suppose that str1, str2, and str3 are string variables. After the following statements above execute, the value of str3 is " ". str1 = "abc"; str2 = "xyz"; str3 = str1 + '-' + str2; The function is used to interchange the contents of two string variables. In C++, the following character '/0' represents. The value of the expression 17 % 7 is. What is the value of alpha[4] after the following code executes? int alpha[5]; int j; alpha[0] = 2; for (j = 1; j < 5; j++) alpha[j] = alpha[j 1] + 3; A variable listed in a function call is known as a(n) parameter. A variable list in a header is known as a(n) parameter.
8 Suppose that x is an int variable. Which of the following expressions always evaluates to true? Given int one; double two; bool four; which of the following assignments are valid? (i) one = 7 * 3 % 4; (ii) = two; (iii) four = (2 <= 3); What is the value of alpha[2] after the following code executes? int alpha[5]; int j; for (j = 0; j < 5; j++) alpha[j] = 2 * j + 1; Suppose x and y are int variables. Consider the following statements. if (x > 5) y = 1; else if (x < 5) { if (x < 3) y = 2; else y = 3; } else y = 4; What is the value of y if x = 6? Which of the following function prototypes is not valid? int funexp(intx,intv); int funexp(intx,intv){};?????? funexp(void); int funexp(void); Which of the following is NOT a reserved word in C++? int cons?
9 num?????? Assume all variables are properly declared. What is the output of the following C++ code? num = 100; while (num <= 150) num = num + 5; cout << num << endl; What is the output of the following C++ code? x = 0; if (x < 0) {cout << "One "; cout << "Two ";} cout << "Three"; What is the output of the following C++ code? int x = 1; do { cout << x << " "; x--; } while (x > 0); cout << endl; Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for loops sets the index of gamma out of bounds The declaration int a, b, c; is equivalent to which of the following????? int a;intb;intc; Given the following function prototype: int test(float, char); which of the following statements is valid? Considering the statement string str = "Gone with the wind";, the output of the statement cout << str.find("the") << endl; is.
10 Which of the following correctly declares and initializes alpha to be an array of 4 rows and 3 columns and the component type is int? Given the function prototype: float test(int, int, int); which of the following statements is legal? Suppose that x = 25.67, y = , and z = What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(2); cout << x << ' ' << y << ' ' << z << endl; In C++, the scope resolution operator is. Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num++; executes. When the function executes, any changes made to the formal parameters passed by value do not in any way affect the parameters. Which of the following is a relational operator? Suppose x is 5 and y is 0. Choose the value of the following expression: (x!= 7) && (!y) What is the value of x after the following satements execute? int x; x = (5 <= 3 && 'A' < 'F')? 3 : 4; What is the output of the following code fragment if the input value is 4? int num; int alpha = 10; cin >> num; switch (num) { case 3: alpha++; break; case 4: case 6:
11 alpha = alpha + 3; case 8: alpha = alpha + 4; break; default: alpha = alpha + 5; } Suppose that you have the following function. void mystery(int& one, int two) { int temp temp = one; one = two; two = temp; } What are the values of x and y after the following statements? (Assume that variables are properly declared.) x = 10; y = 15; mystery(x, y); Consider the following statement. int y =!(12 < 5 3 <= 5 && 3 > x)? 7 : 9; What is the value of y if x = 2? Suppose that x = 87 and y = 423. What is the output of the following statements? cout << " " << endl; cout << setw(5) << x << left << setw(5) << y << setw(7) << "Sunny" << endl; Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3); If a formal parameter is a non-constant reference parameter, its corresponding actual parameter during a function call must be a(n).
12 Consider the following declaration. char chararray[51]; char discard; Assume that the input is: Hello There! How are you? What is the value of discard after the following statements execute? cin.get(chararray, 51); cin.get(discard);???????? Suppose that x and y are int variables. Which of the following is a valid input statement? The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is. Suppose that namestr is a character array of size 21. Which of the following statement is valid in C++? (i) if (strcmp(namestr, "Lisa") == 0) cout << namestr << endl; (ii) if (namestr[0] == 'L') cout << namestr[0] << endl; Consider the statement int list[10][8];. Which of the following about list is true? Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: cin >> x >> ch >> y; Assume that alpha is a character array of size 20. Which of the following statements is illegal in C++?
13 Answer all questions Q1. Write a one line C++ statement to do the following: a. An infinite while loop, without any statement inside the while loop block, using the expression (x < 10) as the decision maker, not x is declared as in integer?. b. Declare a character array to a store a name of a student of 30 character maximum for 100 students? c. A call to function fctx which return no value- the call passes the array student with is declared as int students (5) (10)? Assume all needed variables are declared". d. In the previous question, what would be the function declaration/header. e. Declares the integer array test- score (100) and initializes only the first element of the array to 10? Q.2. given the following structure that contains the social security number and the year ob birth: Struct into (unsighed long soc sec/num). Unsigned int year birth). a. Write a structure called Boo di that contains the following members: info structure, name of type, string. b. write a function named initialize info that takes no parameters but return a structure of type info in which the social security number is initialized to 5511, the name is initialized to Ahmed, and the year to c. Write a main function (including all necessary header files and other parameters) to declare an identifier of type Boo di, initialize, Boo Di by calling the function initialize info
14 Multiple choice: Identify the letter of the choice that best complete the statement or answers the question. 1. Which of the following is not a valid C ++ identifier? a. stop and go. b. salary for the month. c. hello three. d. My counter. 2. which of the following is a reserved word in C++? a. char. b. char. c. CHAR. d. None of these. 3. The value of the C++ expression 14/ is: a. 7 b. 7.3 c. 7.8 d. none of these. 4. Suppose that alpha is a double variable. What is the value of alpha after the following statement executes: a. alpha static- cast < double> (15/2): a. alpha = b. alpha = c. alpha = d. none of these
15 5. Suppose that X and y are int variables, ch is a char variable, and the input is 4 2 A 12. What is the value of x, y, and Ch after the following statement executes <in >> x >> ch>>y, a. x = 4, ch = 2, y= 12. b. x 4, ch= A, y = 12. c. x = 4, ch = ', y = 2. d. this statement results in input failure. 6. Suppose that X = 55.68, y = 476,859 and z = 23, 8216, what is the output of the following statement? Cout << fixed<< showpoint. Cout << setprecision (3). Cout << x << << y << setprecision (2) << z << end1". a ,859 23,82. b , c , 476, d. None of these. 7. Suppose that X = 32, y = 62.93, and Z = what is the output of the following statements" Cout << fixed<< showpoint. Cout << setprecision (3). Cout << x << << y << setprecision (2) << z << end1". Cout << setprecision (3). a Hi b
16 Hi c j. Hi d. None of these. 8. after the execution of the following code, what will be the value of num ifthe input values are 4 5? Cin >> num. If (num > 0). Num = num > 5). Num = num + 15'. a. 4. b. 5. c. 14. d What is the output of the following C ++ code? Int x = 35, Int y = 45. Int z, If (x > y). Z = x + y1 Else Z = y x Cout << x << " << y <<" << z<< end1". a b c d. none of these
17 10. What is the output of the following code fragment if the input value is 4? Int num' Int alpha = 10. Cin >> num, Switch (num). Case 3: alpha ++. Break; Case 4: Case 6: alpha = alpha + 3. Case 8: alpha + 4. Break, Default: alpha = alpha + 5'. Cout << alpha << endl' a. 13. b. 14. c. 15. d
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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.
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 informationC++ Final Exam 2017/2018
1) All of the following are examples of integral data types EXCEPT. o A Double o B Char o C Short o D Int 2) After the execution of the following code, what will be the value of numb if the input value
More informationFORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):
FORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. When you attach & after the datatype in the parameter list of a function, the variable following
More informationFORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each):
FORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each): 1. The basic commands that a computer performs are input (get data), output (display result),
More information5. Assuming gooddata is a Boolean variable, the following two tests are logically equivalent. if (gooddata == false) if (!
FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each): 1. Assume that all variables are properly declared. The following for loop executes 20 times.
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 informationReview Summer CSC1322 Adv Programming in C++ Professor: Zhang
CSC1322 Adv Programming in C++ Professor: Zhang Review Summer 2014 Name: Score: Question Points Score 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 10 19 10 20 10 21 15
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 informationTrue or False (14 Points)
Name Number True or False (14 Points) 1. (15 pts) Circle T for true and F for false: T F a) void functions can use the statement return; T F b) Arguments corresponding to value parameters can be variables.
More informationName SECTION: 12:45 2:20. True or False (12 Points)
Name SECION: 12:45 2:20 rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables
More informationThe University of Alabama in Huntsville Electrical and Computer Engineering CPE Example of Objective Test Questions for Test 4
The University of Alabama in Huntsville Electrical and Computer Engineering CPE 112 02 Example of Objective Test Questions for Test 4 True or False Name: 1. The statement switch (n) case 8 : alpha++; case
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 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 informationClass 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)
Class 2: Variables and Memory Variables A variable is a value that is stored in memory It can be numeric or a character C++ needs to be told what type it is before it can store it in memory It also needs
More informationCPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)
Name rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables retain their value
More informationSuperior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.7. User Defined Functions II
Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.7 User Defined Functions II Prepared for By: Name: ID: Section: Semester: Total Marks: Obtained Marks:
More informationCS 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 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 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 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 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 informationChapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?
Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct and use countercontrolled, sentinel-controlled,
More informationFORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:
FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. The declaration below declares three pointer variables of type pointer to double that is
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 informationName Section: M/W or T/TH. True or False (14 Points)
Name Section: M/W or T/TH True or False (14 Points) 1. (14 pts) Circle T for true and F for false: T F a) In C++, a function definition should not be nested within another function definition. T F b) Static
More informationCSCE 2004 Midterm Exam Spring 2017
CSCE 2004 Midterm Exam Spring 2017 Student Name: Student UAID: Instructions: This is a 50 minute exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers are
More informationWhy Is Repetition Needed?
Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable
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 information1. In C++, reserved words are the same as predefined identifiers. a. True
C++ Programming From Problem Analysis to Program Design 8th Edition Malik TEST BANK Full clear download (no formatting errors) at: https://testbankreal.com/download/c-programming-problem-analysis-program-design-8thedition-malik-test-bank/
More information#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }
1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to
More information6. C++ Subprograms David Keil CS I slides 7/03 1
6. C++ Subprograms David Keil CS I slides 7/03 1 Topic: Subprograms for modularity Modular decomposition Defining C/C++ functions Local variables and scope Value parameters Reference parameters Return
More informationC++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures
More informationCS Spring 05 - MidTerm
CS1411-160 - Spring 05 - MidTerm March 8, 2005 1. When working at the keyboard, the user generates a newline character by pressing the Enter or Return key. 2. In the design of a flag-controlled loop, the
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 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 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 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 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 informationREPETITION CONTROL STRUCTURE LOGO
CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of
More informationIntroduction to C++ (Extensions to C)
Introduction to C++ (Extensions to C) C is purely procedural, with no objects, classes or inheritance. C++ is a hybrid of C with OOP! The most significant extensions to C are: much stronger type checking.
More informationCHAPTER 3 Expressions, Functions, Output
CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number
More informationTrue or False (15 Points)
Name Number True or False (15 Points) 1. (15 pts) Circle T for true and F for false: T F a) Value Returning Functions cannot use reference parameters. T F b) Arguments corresponding to value parameters
More informationIncrement and the While. Class 15
Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment
More informationComputer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:
Computer Department Program: Computer Midterm Exam Date : 19/11/2016 Major: Information & communication technology 1 st Semester Time : 1 hr (10:00 11:00) Course: Introduction to Programming 2016/2017
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 2013 Last Name :... ID:... First Name:... Form
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 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 informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 5: Control Structures II (Repetition) Why Is Repetition Needed? Repetition allows you to efficiently use variables Can input,
More informationKingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS
Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size
More information1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?
Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationCMPS 221 Sample Final
Name: 1 CMPS 221 Sample Final 1. What is the purpose of having the parameter const int a[] as opposed to int a[] in a function declaration and definition? 2. What is the difference between cin.getline(str,
More informationCS 1428 Review. CS 2308 :: Spring 2016 Molly O Neil
CS 1428 Review CS 2308 :: Spring 2016 Molly O Neil Structure of a C++ Program Hello world // This program prints a greeting to the screen #include using namespace std; int main() { cout
More informationFORM 2 (Please put your name and form # on the scantron!!!!)
CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationCS242 COMPUTER PROGRAMMING
CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing
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 informationWindow s Visual Studio Output
1. Explain the output of the program below. Program char str1[11]; char str2[11]; cout > str1; Window s Visual Studio Output Enter a string: 123456789012345678901234567890 Enter
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 informationWARM UP LESSONS BARE BASICS
WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions
More informationCSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 6: One Dimensional Array
Lesson Outcomes At the end of this chapter, student should be able to: Define array Understand requirement of array Know how to access elements of an array Write program using array Know how to pass array
More informationChapter 4 - Notes Control Structures I (Selection)
Chapter 4 - Notes Control Structures I (Selection) I. Control Structures A. Three Ways to Process a Program 1. In Sequence: Starts at the beginning and follows the statements in order 2. Selectively (by
More informationa data type is Types
Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental
More informationCS201- Introduction to Programming Current Quizzes
CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements
More informationLAB 4.1 Relational Operators and the if Statement
LAB 4.1 Relational Operators and the if Statement // This program tests whether or not an initialized value of num2 // is equal to a value of num1 input by the user. int main( ) int num1, // num1 is not
More informationComputer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons
Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite
More informationTrue or False (12 Points)
Name True or False (12 Points) 1. (12 pts) Circle T for true and F for false: T F a) A void function call occurs as part of an expression. T F b) Value Returning Functions cannot have reference parameters.
More informationLecture 4. 1 Statements: 2 Getting Started with C++: LESSON FOUR
1 Statements: A statement in a computer carries out some action. There are three types of statements used in C++; they are expression statement, compound statement and control statement. Expression statement
More informationUEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter
UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter What you will learn from Lab 7 In this laboratory, you will understand how to use typical function prototype with
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 information5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators
Chapter 5: 5.1 Looping The Increment and Decrement Operators The Increment and Decrement Operators The Increment and Decrement Operators ++ is the increment operator. It adds one to a variable. val++;
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 informationLoops and Files. of do-while loop
L E S S O N S E T 5 Loops and Files PURPOSE PROCEDURE 1. To introduce counter and event controlled loops 2. To work with the while loop 3. To introduce the do-while loop 4. To work with the for loop 5.
More informationWeek 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.
Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than
More informationArrays. Week 4. Assylbek Jumagaliyev
Arrays Week 4 Assylbek Jumagaliyev a.jumagaliyev@iitu.kz Introduction Arrays Structures of related data items Static entity (same size throughout program) A few types Pointer-based arrays (C-like) Arrays
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationChapter void Test( int, int, int ); // Function prototype int main() // Function heading { int h; // Local variable
EXERCISE ANSWERS Chapter 7 Exam Preparation Exercises 1 Function call The mechanism that transfers control to the body of a function Argument list A mechanism by which functions communicate with each other;
More informationPointer Basics. Lecture 13 COP 3014 Spring March 28, 2018
Pointer Basics Lecture 13 COP 3014 Spring 2018 March 28, 2018 What is a Pointer? A pointer is a variable that stores a memory address. Pointers are used to store the addresses of other variables or memory
More informationConcepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.
Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical
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 informationLoops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017
Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The
More informationBITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18)
BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18) 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationCHAPTER 4 FUNCTIONS. 4.1 Introduction
CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationDiscussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:
Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;
More informationComputer Programming
Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Lectures 20, 21, 22 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, 1 A Generic Iteration
More informationCMSC 202 Midterm Exam 1 Fall 2015
1. (15 points) There are six logic or syntax errors in the following program; find five of them. Circle each of the five errors you find and write the line number and correction in the space provided below.
More informationTotal 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.
The American University in Cairo Computer Science & Engineering Department CSCE 106 Instructor: Final Exam Fall 2010 Last Name :... ID:... First Name:... Section No.: EXAMINATION INSTRUCTIONS * Do not
More informationCOMP322 - Introduction to C++
COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments
More informationCOMPUTER SCIENCE (083)
Roll No. Code : 112011-083-A Please check that this question paper contains 7 questions and 6 printed pages. CLASS-XI COMPUTER SCIENCE (083) Time Allowed : 3 Hrs. Maximum Marks : 70 General Instructions
More informationReview. Modules. CS 151 Review #6. Sample Program 6.1a:
Review Modules A key element of structured (well organized and documented) programs is their modularity: the breaking of code into small units. These units, or modules, that do not return a value are called
More informationLab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1
Lab 2: Pointers 1. Goals Further understanding of pointer variables Passing parameters to functions by address (pointers) and by references Creating and using dynamic arrays Combing pointers, structures
More informationLooping. Arizona State University 1
Looping CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 5 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationProgramming Fundamentals. With C++ Variable Declaration, Evaluation and Assignment 1
300580 Programming Fundamentals 3 With C++ Variable Declaration, Evaluation and Assignment 1 Today s Topics Variable declaration Assignment to variables Typecasting Counting Mathematical functions Keyboard
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 informationChapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016
Chapter 6: User-Defined Functions Objectives In this chapter, you will: Learn about standard (predefined) functions Learn about user-defined functions Examine value-returning functions Construct and use
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 informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More information