Instructor - C. BoyleFall Semester - 2015

Slides:



Advertisements
Similar presentations
Lecture 2 Introduction to C Programming
Advertisements

Introduction to C Programming
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
Data types and variables
1 Engineering Problem Solving with C++ An Object Based Approach Chapter 2 Simple C++ Programs.
Chapter 2 Data Types, Declarations, and Displays
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Chapter 3: Input/Output
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
Chapter 2 Data Types, Declarations, and Displays.
Objectives You should be able to describe: Data Types
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Due Dates Quiz 1, 2 : Friday September 11 th Quiz 3 : Friday September 18 th Quiz 4 : Monday September 28 th Lab 1, 2 and 3 : Friday Sep 11 th Project.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
Lecture 3: The parts of a C++ program Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
C++ Programming: Basic Elements of C++.
Knowledge Base C++ #include using std namespace; int main(){} return 0 ; cout
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Simple C++ Programs Program Structure Constants and Variables
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
1 What is a Named Constant? A named constant is a location in memory that we can refer to by an identifier, and in which a data value that cannot be changed.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
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.
2/4/2016Engineering Problem Solving with C++, Second Edition, J. Ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs.
Chapter 3 – Variables and Arithmetic Operations. First Program – volume of a box /************************************************************/ /* Program.
Chapter 2 C++ Syntax and Semantics, and the Program Development Process Topics – Programs Composed of Several Functions – Syntax Templates – Legal C++
Chapter 2: Basic Elements of C++. Introduction Computer program – Sequence of statements whose objective is to accomplish a task Programming – Process.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
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.
Bill Tucker Austin Community College COSC 1315
Chapter # 2 Part 2 Programs And data
Today Variable declaration Mathematical Operators Input and Output Lab
Chapter 2: Basic Elements of C++
Chapter 1.2 Introduction to C++ Programming
Chapter 2: Basic Elements of C++
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Computer Programming BCT 1113
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
INSPIRING CREATIVE AND INNOVATIVE MINDS
Basic Elements of C++.
Revision Lecture
Introduction to C++.
Basic Elements of C++ Chapter 2.
Chapter 2 - Introduction to C Programming
2.1 Parts of a C++ Program.
Programming Funamental slides
Chapter 3: Input/Output
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Chapter 3 Input output.
Introduction to C++ Programming
Chapter 2: Introduction to C++.
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Fundamental Programming
An Introduction to Programming with C++ Fifth Edition
C++ Programming Basics
Introduction to C Programming
Presentation transcript:

Instructor - C. BoyleFall Semester

This was an in-class exercise, and something may have changed, SO Do not count on the accuracy of the solutions in this presentation! Verify With Your Textbook! Look Up The Answers Yourself!

Q#1 Question Which of the following methods for inserting comments in a C++ program are valid? Answer \\ comments in your program \* comments in your program *\ /* comments in your program */ #comments in your program

Q#1-Solution There are two methods for inserting comments in a C++ program: a comment can begin with the characters // or a comment can begin with the characters /* and then end with the characters */

Q#2 Question Question True or False: The setw manipulator cannot use a string as an argument. Answer True False

Q#3 Question Consider the following preprocessor directive: #include The directive specifies that the statements in the file: ANSWER contains a constant we use in executing loops. contains information related to the input statement used in the program contains info related to functions used to compute the sum of a value. contains a comment we use in exiting the program.

Q#4 Question Multiple Answer Question The main function contains two types of statements: Answer statements that define memory locations which will be used in the program pre-processor statements that define additional code to be inserted. statements that specify actions to be taken. post-processor statements that define additional code to executed.

Q#5 Question Question True or False: The if…else statement is a one-way selection structure. Answer True False

Q#6 Question Multiple Answer Question //define and initialize variables double quizscore1, quizscore3, quiz4=10, averagescore=4.0, avg, sumscores; This statement specifies that Answer the program will use five variables. the variable quiz4 should be initialized to the value of the variable average should be initialized to the value of nothing, because it should all be on one line.

Q#7 Question Question Rules for selecting a valid identifier are: Answer An identifier cannot begin with an alphabetic character or the underscore character. Alphabetic characters in an identifier must be lower case letters. An identifier can be of any length. Alphabetic characters in an identifier can be lower case or upper case letters.

Q#8 Question Question The following is a valid identifier: 1_quiz Answer True False

Q#9 Question Question The following is a valid identifier: max-value Answer True False

Q#10 Question Question The following is a valid identifier: $uperMan Answer True False

Q#11 Question Question True or False: File stream variables are predefined in the fstream header file and associated with input/output sources. Answer True False

Q#12 Question Question C++ is case sensitive, that is, it distinguishes upper case letters from lowercase letters. Thus Sum, sum, and SUM represent three ways of safely working with the same variable value. Answer True False

Q#13 Question Question The difference between the float, double, and long double types relates to the Answer exponent (or accuracy) and length of the values represented. precision (or accuracy) and range of the values represented. exponent (short accuracy), range (long accuracy) and length of the values represented. precision (or accuracy) and range of the libraries included.

Q#14 Question Question A float value will have a wider range of values for exponents than a double value. Answer True False

Q#15 Question Multiple Answer Question Select the true statements, concerning symbolic constants: Answer The compiler will replace each occurrence of the constant identifier with the constant value. Constant declarations, like variable declarations, and with a colon. ( : ) Several symbolic constants can be declared in one statement if they have the same data type. A symbolic constants is declared by prefixing a declaration with the const specifier.

Q#16 Question Question The assignment statements below define and initialize the variables at the same time. double sum, total; total = 10; sum = total; Answer True False

Q#17 Question Question Multiple assignments are allowed in C++, as in the following statement, which assigns a value of zero to each of the variables x,y, and z. x = y = z = 0; Answer True False

Q#18 Question Question What is an enumeration type? Answer C++’s method for allowing programmers to create their own simple data types. C++’s method for allowing programmers to use numerals to update control structures. One of C++’s simple integer data types, such as int. C++’s library of available numerical variables.

Q#19 Question Question An expression that has operands of different data types is called a(n) Answer mixed expression homogenous expression simple enumerated expression

Q#20 Question Question What is the syntax for declaring single or multiple variables? Answer dataType identifier, identifier, …; variableName dataType identifier, identifier, …; dataName identifierType, identifierType, …; identifier, identifier, …;

Q#21 Question Question True or False: The semantic rules of a language tell you what is legal and what is not legal. Answer True False

Q#22 Question Question What is the syntax of the ignore function? Answer cin.ignore(intExp, chExp); cout<< stringName.ignore(intExp, intExp); cin>> stringName.ignore(intExp, intExp); int value.stringName.ignore(intExp, intExp);

Q#23 Question Question The header file ______________ needs to be included to use the setw function. Answer iomanip iostream iosetw cmath

Q#24 Question Question Which of the following would you use as a statement to format the output of decimal numbers to two decimal places? Answer cout << setprecision(2); cin << setprecision(2); cout << setdotwidth( ); cout >> setw.setprecision(2);

Q#25 Question Question Which of the following are true? Answer The if…else statement is a two-way selection structure. A unary operator takes three operands. The equality operator in C++ is = A relational operator allows you to make comparisons in a program.

QUESTIONS?Assignments: Quiz due before class on Tuesday