# Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

Size: px
Start display at page:

Transcription

1 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 D. string F #Hashtag E. boolean C '+' F. none of the above. A -85 E true C '\'' 2. For each of the following determine if it is a valid identifier, and if it is not state why. A. House# not valid, # is not allowed in identifier B. 2nd not valid, identifiers must start with letter or underscore not a number C. WHILE valid D. num4 valid E. double not valid, double is a keyword F. last_name valid 3. Evaluate the following expressions A. (4-7) * 3-9 B. 14 % 4 2 C. 24 / 9 2 D / E * What is the output of the following program. #include <iostream> #include <iomanip> using namespace std; int main () { int hr, min; hr = 1; min = 50; cout << "The exam is over at " << hr << : << min << endl; cout << "One down\n " << two to go! ; return 0; } The exam is over at 1:50 One down two to go!

2 5. What is the output of the following program #include <iostream> #include <iomanip> using namespace std; int main() { int WholeNumber; double Real1, Real2; WholeNumber = 76; Real1 = 3.167; Real2 = ; cout << setw(6) << WholeNumber << endl; cout << setiosflags(ios::fixed); cout << setprecision(2) << Real1 << ", " << Real2 << endl; cout << setiosflags(ios::showpoint) << Real2 << << endl; return 0; } , Which of the following are valid on the left side of an assignment operator? A. A numeric constant B. An expression such as 8*6 C. A declared constant D. A variable E. All of the above are valid on the left side of an assignment operator. 7. Which of the following are valid on the right side of an assignment operator? A. A numeric constant B. An expression such as 8*6 C. A declared constant D. A variable E. All of the above are valid on the right side of an assignment operator. 8. The operator >> is used to A. Extract a value from the input stream and assign it to a variable B. Take a value from a variable and place it into the output stream C. Perform integer division and produce the remainder of the division D. Specify that the left hand operand is much larger than the right hand operand. 9. The file which must appear in a #include preprocessor statement if you are using the fabs function is A. iostream B. iomanip C. cmath D. string

3 10. Which of the following is not a data type used to represent a floating point value A. float B. double C. long double D. short 11. Which of the following is not a syntactically correct declaration? A. int number(12); B. double value1(4.5); value2(3.7); C. double tax_percent =0.06; D. double x{0.0}; E. int x,y,z; 12. Which of the following operators is the increment operator A. += B. + C. % D Which output flag is set to guarantee that a decimal point will be printed when printing a floating point value? A. fixed B. showpoint C. precision D. setw 14. Function arguments are A. the term used for the name of the function B. the term that refers to the value returned by a function C. the term that refers to the values passed to the function when the function is invoked. D. the term that refers to a function invocation. 15. Which of the following function invocations is an approximation of PI A. atan(-1); B. acos(-1); C. sin(-1); D. cos(-1); 16. Line comments begin with // and run for the rest of the line 17. The purpose of a comment is to help the compiler understand your program and create efficient object code.

4 18. The math function sin will compute sine when given the angle in degrees 19. The setw manipulator is used to set the field width for all values that are printed until another setw manipulator is encountered. 20. The preprocessor directive #include <iostream> copies the file iostream into the program before compilation, so that the program can use input and output objects and operators. 21. The operand of the increment operator may be either a declared constant or a variable. 22. The math function tan will compute tangent when the angle is given in radians. 23. In a case sensitive language, such as C++, the variables apples and APPLES refer to different storage locations. 24. An expression involving operators can appear after the output operator << in a cout statement. 25. The precision of a floating point number is determined by the number of bits used to represent the exponent. 26. Given the declaration auto i = 0; i is declared as an int. 27. Given the declaration auto i = 1.0; i is declared as type double.

5 28. C++ is a strongly typed programming language. C. 29. Symbolic constants in C++ are declared with the modifier const; attempting to change the value of a symbolic constant will be flagged as a syntax error by the compiler. 30. Class declarations specify a programmer-defined type/object. 31. Class members may include data (attributes) and methods (functions). 32. Which of the following visibilities by be used to control access to class members: A. public B. protected C. private D. All of these are visibilities used to control access to class members. 33. Class attributes define the operations that may be performed on class objects. 34. Constructors are special methods of a class that are executed when objects of the class type are created. 35. Constructors must have the same name as the class 36. There must be exactly one constructor defined in every class. 37. Once a class is defined, you may use the class as a type specifier.

6 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 1.427E3 B. double "Oct" C. character D. string #Hashtag E. boolean '+' F. none of the above. -85 true '\'' 2. For each of the following determine if it is a valid identifier, and if it is not state why. A. House# B. 2nd C. WHILE D. num4 E. double F. last_name 3. Evaluate the following functions A. (4-7) * 3 B. 14 % 4 C. 24 / 9 D / 4.2 E * What is the output of the following program. #include <iostream> #include <iomanip> using namespace std; int main () { int hr, min; hr = 1; min = 50; cout << "The exam is over at " << hr << : << min << endl; cout << "One down\n " << two to go! ; return 0; }

7 5. What is the output of the following program #include <iostream> #include <iomanip> using namespace std; int main() { int WholeNumber; double Real1, Real2; WholeNumber = 76; Real1 = 3.167; Real2 = ; cout << setw(6) << WholeNumber << endl; cout << setiosflags(ios::fixed); cout << setprecision(2) << Real1 << ", " << Real2 << endl; cout << setiosflags(ios::showpoint) << Real2 << << endl; return 0; } 6. Which of the following are valid on the left side of an assignment operator? A. A numeric constant B. An expression such as 8*6 C. A declared constant D. A variable E. All of the above are valid on the left side of an assignment operator. 7. Which of the following is valid on the right side of an assignment operator? A. A numeric constant B. An expression such as 8*6 C. A declared constant D. A variable E. All of the above are valid on the right side of an assignment operator. 8. The operator >> is used to A. Take a value from the input stream an store it into a variable B. Take a value from a variable and place it into the output stream C. Perform integer division and produce the remainder of the division D. Specify that the left hand operand is much larger than the right hand operand. 9. The file which must appear in a #include preprocessor statement if you are using the fabs function is A. iostream B. iomanip C. cmath D. string

8 10. Which of the following is not a data type used to represent a floating point value A. float B. double C. long double D. short 11. Which of the following is not a syntactically correct declaration? A. int number(12); B. double value1(4.5); value2(3.7); C. double tax_percent =0.06; D. double x{0.0}; E. int x,y,z; 12. Which of the following operators is the increment operator A. += B. + C. % D Which output flag is set to guarantee that a decimal point will be printed when printing a floating point value? A. fixed B. showpoint C. precision D. setw 14. Function arguments are A. the term used for the name of the function B. the term that refers to the value returned by a function C. the term that refers to the values passed to the function when the function is invoked. D. the term that refers to a function invocation. 15. Which of the following function invocations is an approximation of PI A. atan(-1); B. acos(-1); C. sin(-1); D. cos(-1); 16. Line comments begin with // and run for the rest of the line 17. The purpose of a comment is to help the compiler understand your program and create efficient object code.

9 18. The math function sin will compute sine when given the angle in degrees 19. The setw manipulator is used to set the field width for all values that are printed until another setw manipulator is encountered. 20. The preprocessor directive #include <iostream> copies the file iostream into the program before compilation, so that the program can use input and output objects and operators. 21. The operand of the increment operator may be either a declared constant or a variable. 22. The math function tan will compute tangent when the angle is given in radians. 23. In a case sensitive language, such as C++, the variables apples and APPLES refer to different storage locations. 24. An expression involving operators can appear after the output operator << in a cout statement. 25. The precision of a floating point number is determined by the number of bits used to represent the exponent. 26. Given the declaration auto i = 0; i is declared as an int. 27. Given the declaration auto i = 1.0; i is declared as a double

10 28. C++ is a strongly typed programming language.

11 29. Symbolic constants in C++ are declared with the modifier const; attempting to change the value of a symbolic constant will be flagged as a syntax error by the compiler. 30. Class declarations specify a programmer-defined type/object. 31. Class members may include data (attributes) and methods (functions). 32. Which of the following visibilities by be used to control access to class members: A. public B. protected C. private D. All of these are visibilities used to control access to class members. 33. Class attributes define the operations that may be performed on class objects. 34. Constructors are special methods of a class that are executed when objects of the class type are created. 35. There may be exactly one constructor defined in any class. 36. Constructors must have the same name as the class. 37. Once a class is defined, you may use the class as a type specifier.

### BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token

### Chapter 2. Outline. Simple C++ Programs

Chapter 2 Simple C++ Programs Outline Objectives 1. Building C++ Solutions with IDEs: Dev-cpp, Xcode 2. C++ Program Structure 3. Constant and Variables 4. C++ Operators 5. Standard Input and Output 6.

### Engineering Problem Solving with C++, Etter/Ingber

Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs C++, Second Edition, J. Ingber 1 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input

### C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

### Review: 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

### The cin Object. cout << "Enter the length and the width of the rectangle? "; cin >> length >> width;

The cin Object Short for console input. It is used to read data typed at the keyboard. Must include the iostream library. When this instruction is executed, it waits for the user to type, it reads the

### C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

### Definition 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

### Chapter 3. Numeric Types, Expressions, and Output

Chapter 3 Numeric Types, Expressions, and Output 1 Chapter 3 Topics Constants of Type int and float Evaluating Arithmetic Expressions Implicit Type Coercion and Explicit Type Conversion Calling a Value-Returning

### 3.1. Chapter 3: The cin Object. Expressions and Interactivity

Chapter 3: Expressions and Interactivity 3.1 The cin Object Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 3-1 The cin Object Standard input stream object, normally the keyboard,

### CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library

### I/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

### Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific

### LECTURE 02 INTRODUCTION TO C++

PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION

### c++ 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

### Getting 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

### CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing Lecture 4-5 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 3 Assignment, Formatting, and Interactive Input

### The 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

### C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

C++ PROGRAMMING For Industrial And Electrical Engineering Instructor: Ruba A. Salamh CHAPTER TWO: Fundamental Data Types Chapter Goals In this chapter, you will learn how to work with numbers and text,

### Structured Programming. Flowchart Symbols. Structured Programming. Selection. Sequence. Control Structures ELEC 330 1

ELEC 330 1 Structured Programming Control Structures ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne Algorithm Development Conditional Expressions Selection Statements Loops 206_C3

### CS 151 Review #3. // More than one variable can be defined // in a statement. Multiple variables are // separated by a comma.

REVIEW cout Statement The cout statement invokes an output stream, which is a sequence of characters to be displayed to the screen. cout

### 2 nd Week Lecture Notes

2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

### CSCE 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,

### CSCE 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,

### Lecture 4 Tao Wang 1

Lecture 4 Tao Wang 1 Objectives In this chapter, you will learn about: Assignment operations Formatting numbers for program output Using mathematical library functions Symbolic constants Common programming

Slide 7-1 Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Type Conversation / Casting Name Constant - const, #define X When You Mix Apples and Oranges: Type Conversion Operations

### 2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

### CHAPTER 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

### 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

### Introduction to Programming EC-105. Lecture 2

Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically

### Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

### Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look

### Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Lecture 3 Winter 2011/12 Oct 25 Visual C++: Problems and Solutions New section on web page (scroll down)

### CHAPTER 3 BASIC INSTRUCTION OF C++

CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers

### Intro 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

### A First Program - Greeting.cpp

C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

### Chapter 2: Overview of C++

Chapter 2: Overview of C++ Problem Solving, Abstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman C++ Background Introduced by Bjarne Stroustrup of AT&T s Bell Laboratories in

### The following is a typical execution run of this program:

et181:endterm test, fall 2010 (200 points) name: Closed notes, open book, two hour test. You may use any graded program of your choice. There are four sections on eight pages. Each section is worth 50

### Expressions, Input, Output and Data Type Conversions

L E S S O N S E T 3 Expressions, Input, Output and Data Type Conversions PURPOSE 1. To learn input and formatted output statements 2. To learn data type conversions (coercion and casting) 3. To work with

### PASS\$MOCK\$EXAM\$ \$FOR\$PRACTICE\$ONLY\$

PASS\$MOCK\$EXAM\$ \$FOR\$PRACTICE\$ONLY\$ Course: ECOR 1606 Facilitator: Dane Levere Dates and locations of take-up: Wednesday April 23 rd, 2014 12:00pm-3:00pm LA C164 IMPORTANT: It is most beneficial to you

### CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

### Introduction 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.

### ! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

Week 1 Operators, Data Types & I/O Gaddis: Chapters 1, 2, 3 CS 5301 Fall 2016 Jill Seaman Programming A program is a set of instructions that the computer follows to perform a task It must be translated

### Chapter 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:

### Multiple 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

### Objectives. 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

### Chapter 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

### For 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

### Chapter 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

### Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

### VARIABLES & ASSIGNMENTS

Fall 2018 CS150 - Intro to CS I 1 VARIABLES & ASSIGNMENTS Sections 2.1, 2.2, 2.3, 2.4 Fall 2018 CS150 - Intro to CS I 2 Variables Named storage location for holding data named piece of memory You need

### a. a * c - 10 = b. a % b + (a * d) + 7 =

Exam #2 CISC1110, MW 10:35-12:40pm Fall 2011 Name 1 Evaluate each expression according to C++ rules (8 pts) Given: Integers a = 3, b = 2, c = 5, and float d = 40 a a * c - 10 = b a % b + (a * d) + 7 =

### 3.1. Chapter 3: Displaying a Prompt. Expressions and Interactivity

Chapter 3: Expressions and Interactivity 3.1 The cin Object Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

### WARM 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

### Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of

### Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is

### C++, How to Program. Spring 2016 CISC1600 Yanjun Li 1

Chapter 6 Function C++, How to Program Deitel & Deitel Spring 2016 CISC1600 Yanjun Li 1 Function A function is a collection of statements that performs a specific task - a single, well-defined task. Divide

### Week 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

### Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces

Basic memory model Using functions Writing functions Basics Prototypes Parameters Return types Functions and memory Names and namespaces When a program runs it requires main memory (RAM) space for Program

### Chapter 3: Expressions and Interactivity. Copyright 2012 Pearson Education, Inc. Thursday, October 9, 14

Chapter 3: Expressions and Interactivity 3.1 The cin Object The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Information retrieved from cin with >>

### Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10

### Example 3. #include <iostream> using namespace std; int main()

1 Repetition Structure Examples Example 1 #include float number, sum=0; // number to be read cin >> number; // read first number cout

### Objectives. In this chapter, you will:

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 arithmetic expressions Learn about

### Programming 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

### Introduction to C++ Dr M.S. Colclough, research fellows, pgtas

Introduction to C++ Dr M.S. Colclough, research fellows, pgtas 5 weeks, 2 afternoons / week. Primarily a lab project. Approx. first 5 sessions start with lecture, followed by non assessed exercises in

### ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants

### The 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

### Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing

### Chapter 3 - Functions

Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number

### Programming. 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++

### 3.1. Chapter 3: The cin Object in Program 3-1. Displaying a Prompt 8/23/2014. The cin Object

Chapter 3: Expressions and Interactivity 3.1 The cin Object The cin Object The cin Object in Program 3-1 Standard input object Like cout, requires iostream file Used to read input from keyboard Information

### Chapter 3: Expressions and Interactivity

Chapter 3: Expressions and Interactivity 3.1 The cin Object The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Information retrieved from cin with >>

### Chapter 3 Problem Solving and the Computer

Chapter 3 Problem Solving and the Computer An algorithm is a step-by-step operations that the CPU must execute in order to solve a problem, or to perform that task. A program is the specification of an

### ! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc.

Week 1: Introduction to C++ Gaddis: Chapter 2 (excluding 2.1, 2.11, 2.14) CS 1428 Fall 2014 Jill Seaman Literals A literal represents a constant value used in a program statement. Numbers: 0, 34, 3.14159,

### CS2141 Software Development using C/C++ Stream I/O

CS2141 Software Development using C/C++ Stream I/O iostream Two libraries can be used for input and output: stdio and iostream The iostream library is newer and better: It is object oriented It can make

### Functions and Recursion

Functions and Recursion 1 Outline Introduction Program Components in C++ Math Library Functions Functions Function Definitions Function Prototypes Header Files Random Number Generation Example: A Game

### UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . \$, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

### Multiple 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

### Computer Programming : C++

The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

### PIC 10A. Review for Midterm I

PIC 10A Review for Midterm I Midterm I Friday, May 1, 2.00-2.50pm. Try to show up 5 min early so we can start on time. Exam will cover all material up to and including todays lecture. (Only topics that

### PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

### Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

### CS242 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

### Programming Language. Functions. Eng. Anis Nazer First Semester

Programming Language Functions Eng. Anis Nazer First Semester 2016-2017 Definitions Function : a set of statements that are written once, and can be executed upon request Functions are separate entities

### Computing and Statistical Data Analysis Lecture 3

Computing and Statistical Data Analysis Lecture 3 Type casting: static_cast, etc. Basic mathematical functions More i/o: formatting tricks Scope, namspaces Functions 1 Type casting Often we need to interpret

### Introduction to Programming

Introduction to Programming session 9 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel s slides Sahrif University of Technology Outlines

### CS201 Solved MCQs.

15.1 Answer each of the following: a. Input/output in C++ occurs as of bytes. b. The stream manipulators that format justification are, and. c. Member function can be used to set and reset format state.

### Programming with C++ as a Second Language

Programming with C++ as a Second Language Week 2 Overview of C++ CSE/ICS 45C Patricia Lee, PhD Chapter 1 C++ Basics Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Introduction to

### 6.096 Introduction to C++ January (IAP) 2009

MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

### By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

### CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

### The 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. Howaida Ismail Final Exam Spring 2013 Last Name :... ID:... First Name:...

### Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

### C++ 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:

### The 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

### Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Computer Systems Computer System Computer Structure C++ Environment Imperative vs. object-oriented programming in C++ Input / Output Primitive data types Software Banking System Compiler Music Player Text

### PROGRAMMING 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