Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Size: px
Start display at page:

Download "Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program."

Transcription

1 Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to and that other programmers can understand. 2. Computers are designed to respond to heuristic commands. 3. A data object consists of exactly one piece of data. 4. When all of the statements in a source program are translated before any one statement is executed, the programming language used is called a compiled language. 5. A keyword is a word that is set aside by the C++ language for a special purpose and should only be used in a specified manner. 6. A good function name should never be a mnemonic. 7. A C++ program does not always require a main() function. 8. The iostream file is referred to as a header file because a reference to it is always placed at the top, or head, of a C++ program using the #include command. 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. 10. Properly coded programs do not need comments if the program code is self-explanatory. 11. To prevent the programmer from attempting to perform an inappropriate operation, C++ allows only certain operations to be performed on certain types of data. 12. The term literal reflects the fact that such a value explicitly identifies itself. 13. Limitations of small and extremely expensive memory are a major concern for the vast majority of programs. 14. When the escape character is placed directly in front of a select group of characters, it tells the compiler to escape from the way these characters would normally be interpreted. 15. Both the char and bool data types are signed data types. 16. Floating-point numbers cannot be written in exponential notation. 17. Character data cannot be displayed using cout. 2

2 Name: 18. The endl item is an example of an escape sequence. 19. C++ does not allow mixed-mode expressions. 20. Two binary arithmetic operator symbols may be placed side by side. 21. Expressions containing more than one addition or subtraction are evaluated from left to right as each operator is encountered. 22. An operator s associativity establishes its priority in relation to all other operators. 23. Assignment statements always have an equals (=) sign and one variable name immediately to the left of this sign. 24. Variables that hold single-precision values are declared using the keyword float, whereas variables that hold double-precision values are declared using the keywords double float. 25. Variables that have the same data type can always be grouped together and declared by using a single declaration statement. 26. Declaring multiple variables in a single declaration statement requires giving the data type of variables only once, separating all variable names by commas, and using only one semicolon to terminate the declaration. 27. Current C++ compilers can allocate sufficient storage for a variable without knowing the variable s data type. 28. The compiler only generates an error message for undeclared variables if they are not used in the program. 29. An expression is any combination of constants, variables, and function calls that can be evaluated to yield a result. 30. An example of coercion occurs when an integer value is assigned to a real variable. 31. The statement sum = sum + 10; causes a new value to be stored in sum. 32. The statement variable = variable + newvalue; is an example of an accounting statement. 33. The argument to the sqrt function must be a rational number. 34. The expression sqrt(pow(abs(num1), num2)) is a valid expression. 35. The C type cast syntax does not work in C Data for programs that are going to be executed only once should never be included directly in the program. 37. A well-constructed program should validate user input and ensure that a program does not either crash or produce nonsensical output due to unexpected input. 2

3 Name: 38. C++ does not provide a way for programmers to assign symbolic names to constants, such as the mathematical constant PI. 39. The expression (count + n)++ is a valid expression. 40. Relational expressions cannot be used to compare operands. 41. The logical operators AND, OR and NOT are used to create more complex relational expressions. 42. Tests for equality of single-precision and double-precision values and variables using the relational operator == are usually reliable. 43. The if-else statement directs the computer to select between two statements based on the result of a comparison. 44. The use of braces to enclose a set of individual statements creates a single block of statements, which may be used anywhere in a C++ program in place of a single statement. 45. The statement following if (expression) is executed only if the expression has a nonzero value (a true condition). 46. if-else statements can not contain other if-else statements. 47. An if-else chain is stopped once a true condition is found. 48. An if-else chain can not be continued indefinitely by repeatedly making the last statement another if-else statement. 49. In a switch statement, the keyword case is used to identify individual values that are compared to the value of the switch expression. 50. Using the assignment operator, =, in place of the relational operator, ==, is a commonly made C++ programming error. Multiple Choice Identify the choice that best completes the statement or answers the question. 1. Another term for a computer program is. a. hardware c. object b. software d. procedure 2. Programs written in low-level languages usually execute than programs written in high-level languages. a. more accurately c. faster b. less accurately d. slower 3

4 Name: 3. The purpose of a procedure is to accept as input and transform it in some manner to produce a specific result as an output. a. numbers c. formulas b. objects d. data 4. An algorithm is a step-by-step sequence of that describes how a computation is to be performed. a. data c. objects b. instructions d. classes 5. When English-like phrases are used to describe an algorithm (the processing steps), the description is called. a. a formula c. a program b. a flowchart d. pseudocode 6. The writing of an algorithm using computer-language statements is called the algorithm. a. compiling c. interpreting b. coding d. debugging 7. The concept of creating a particular object from a larger defining set called a is fundamental to all object-oriented programming languages, such as C++. a. super-set c. class b. master set d. relationship 8. To generate a program that can be executed by the computer requires that the C++ program, which is referred to as a source program, be translated into the computer s. a. data c. objects b. machine language d. classes 9. You cannot write a C++ program without relying on some. a. high level code c. machine language b. procedural code d. pseudocode 10. A(n) program is simply a translated version of the source program that can be executed by the computer system with one more processing step. a. compiled c. object b. debugged d. C Most C++ programs contain statements that use for input and output and for finding such quantities as square roots, absolute values, and other commonly encountered mathematical calculations. a. classes c. databases b. objects d. preprogrammed routines 12. In C++, modules can be either or functions. a. classes c. objects b. methods d. procedures 13. The first character of an identifier must be a or an underscore (_). a. number c. letter b. mnemonic d. special character 4

5 Name: 14. We can tell the program which class or function to use by indicating the where we want the compiler to look for the class or function. a. location c. module b. address d. namespace 15. A programming language s is the set of rules for formulating statements that are grammatically correct for the language. a. syntax c. dictionary b. namespace d. format 16. A data is defined as a set of values and a set of operations that can be applied to these values. a. type c. base b. set d. dictionary 17. A(n) value consists of digits only and can optionally be preceded by a plus (+) or minus (-) sign. a. integer c. floating-point b. char d. signed 18. The ANSI C++ standard requires that an int must provide as much storage as a short int. a. at least c. three times b. twice d. four times 19. The value of 1.625e3 is. a c b d The C++ statement cout << (6 + 15); yields the result. a. (6 + 15) c. error b. 21 d. (21) 21. The keyword endl is an example of a C++. a. literal c. object b. character d. manipulator 22. An expression containing only integer values as operands is called a(n) expression. a. standard c. regular b. whole d. integer 23. An expression containing only floating-point values (single-precision and double-precision) as operands is called a expression. a. complex c. real b. mixed d. block 24. An expression containing integer and floating-point values is called a expression. a. whole c. mixed-mode b. standard d. real 25. statements are used to force the compiler to reserve enough physical memory storage for each variable. a. Initialization c. Declamation b. Assignment d. Definition 5

6 Name: 26. All operands used in an expression must before the expression is evaluated. a. have values assigned to them c. be parameterized b. be simplified d. be printed out 27. If b is an integer and d is a double-precision number, the evaluation of the expression b*d is a(n) value. a. integer c. real b. float d. double-precision 28. If n is initialized to the value 5, the expression --n changes the value of n to. a. 1 c. 5 b. 4 d In C++ there are square root functions all named sqrt, with the data type of the argument determining which function is actually called. a. one c. three b. two d. four 30. The compile-time cast is a operator having the syntax datatype (expression). a. unary c. coercive b. binary d. switch 31. The cin object is used to enter data into a program while it is. a. compiling c. interpreting b. running d. loading 32. When a cout statement prints a string that tells the person at the terminal what should be typed, the output string used in this manner is called a(n). a. prompt c. interrupt b. checkpoint d. pause 33. The cin extraction operation data type conversions. a. always makes the correct c. can make some b. can make no d. makes only integer to float 34. The const qualifier specifies that the declared identifier is read-only after it is. a. defined c. edited b. initialized d. validated 35. If it is necessary to change the value of a constant with a symbolic name, the change need only be made. a. at compile time c. twice b. once d. at execution time 36. Using letters is customary in C++ to make const identifiers easy to identify. a. lowercase c. bold b. italic d. uppercase 37. The increment and decrement operators can be applied only to variables. a. expressions involving two or fewer c. individual b. expressions involving three or fewer d. real 6

7 Name: 38. The extraction operator used with cin is. a. << c., b. >> d. <> 39. One of the most common C++ programming errors is forgetting to values for all variables that are used in an expression. a. assign or initialize c. compute b. read in d. parameterize 40. A computer s capability can be used to create an intelligence-like facility. a. adding c. subtracting b. comparison d. thinking 41. A relational expression consists of a relational operator connecting two variable and/or constant operands. a. standard c. single b. default d. simple 42. Like all C++ expressions, relational expressions are evaluated to yield a result. a. single-precision c. Boolean b. double-precision d. numerical 43. letters is essential in alphabetizing names. a. Comparing c. Deleting b. Capitalizing d. Adding 44. can be used to alter the assigned operator priority and improve the readability of relational expressions. a. Colons c. Parentheses b. Semicolons d. Braces 45. Many numbers cannot be represented exactly in binary form using a finite number of bits. a. small c. integer b. large d. decimal 46. For single-precision and double-precision operands, the general expression operand_1 == operand_2 should be replaced by this condition: a. operand_1 operand_2 < EPSILON b. abs(operand_1 operand_2) < EPSILON c. operand_2 operand_1 < EPSILON d. operand_1 operand_2 >= EPSILON 47. Using to enclose a set of statements creates a single block of statements. a. semicolons c. parentheses b. colons d. braces 48. If age is initialized to equal 18, the statement age == 40 has a value of. a. 0 c. 18 b. 1 d case labels may be contained within a switch statement. a. Up to 1 c. Up to 100 b. Up to 10 d. Any number of 7

8 Name: 50. It is to terminate the last case in a switch statement with a break. a. required c. a syntax error b. mandatory d. not necessary 8

9 Exam #1 - Prep Answer Section TRUE/FALSE 1. ANS: T PTS: 1 REF: 4 2. ANS: F PTS: 1 REF: 5 3. ANS: F PTS: 1 REF: 9 4. ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: ANS: F PTS: 1 REF: 138 1

10 41. ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: F PTS: 1 REF: ANS: T PTS: 1 REF: ANS: T PTS: 1 REF: 173 MULTIPLE CHOICE 1. ANS: B PTS: 1 REF: 3 2. ANS: C PTS: 1 REF: 4 3. ANS: D PTS: 1 REF: 4 4. ANS: B PTS: 1 REF: 5 5. ANS: D PTS: 1 REF: ANS: B PTS: 1 REF: 8 7. ANS: C PTS: 1 REF: 9 8. ANS: B PTS: 1 REF: 9 9. ANS: B PTS: 1 REF: ANS: C PTS: 1 REF: ANS: D PTS: 1 REF: ANS: A PTS: 1 REF: ANS: C PTS: 1 REF: ANS: D PTS: 1 REF: ANS: A PTS: 1 REF: ANS: A PTS: 1 REF: ANS: A PTS: 1 REF: ANS: A PTS: 1 REF: ANS: C PTS: 1 REF: ANS: B PTS: 1 REF: ANS: D PTS: 1 REF: ANS: D PTS: 1 REF: ANS: C PTS: 1 REF: ANS: C PTS: 1 REF: ANS: D PTS: 1 REF: ANS: A PTS: 1 REF: ANS: D PTS: 1 REF: ANS: B PTS: 1 REF: ANS: C PTS: 1 REF: ANS: A PTS: 1 REF: ANS: B PTS: 1 REF: ANS: A PTS: 1 REF: 118 2

11 33. ANS: C PTS: 1 REF: ANS: B PTS: 1 REF: ANS: B PTS: 1 REF: ANS: D PTS: 1 REF: ANS: C PTS: 1 REF: ANS: B PTS: 1 REF: ANS: A PTS: 1 REF: ANS: B PTS: 1 REF: ANS: D PTS: 1 REF: ANS: D PTS: 1 REF: ANS: A PTS: 1 REF: ANS: C PTS: 1 REF: ANS: D PTS: 1 REF: ANS: B PTS: 1 REF: ANS: D PTS: 1 REF: ANS: A PTS: 1 REF: ANS: D PTS: 1 REF: ANS: D PTS: 1 REF: 171 3

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors

More information

Chapter 2: Problem Solving Using C++

Chapter 2: Problem Solving Using C++ Chapter 2: Problem Solving Using C++ 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common

More information

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 2: Basic Elements of C++

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with the basic components of a C++ program,

More information

Adjusted/Modified by Nicole Tobias. Chapter 2: Basic Elements of C++

Adjusted/Modified by Nicole Tobias. Chapter 2: Basic Elements of C++ Adjusted/Modified by Nicole Tobias 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

More information

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

More information

Chapter 2: Basic Elements of C++

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

More information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Chapter 4 Operators & Arithmetic

Chapter 4 Operators & Arithmetic Chapter 4 Operators & Arithmetic 4-1 Arithmetic in C++ Arithmetic expressions can be made up of constants, variables, operators and parentheses. The arithmetic operators in C++ are as follows + (addition)

More information

Control Structure. Pseudocode: Input number If number is even Then Print even Else print odd. Flowchart: Begin. End. Print Odd. number even?

Control Structure. Pseudocode: Input number If number is even Then Print even Else print odd. Flowchart: Begin. End. Print Odd. number even? Control Structure Normally, a program is executed in a sequential manner.however, in many cases, a program has to choose among alternative statements C++ provides constructs that enable the programmer

More information

Comp181 Midterm Examination, Fall Name Surname: Number: 90 min. 18/11/09

Comp181 Midterm Examination, Fall Name Surname: Number: 90 min. 18/11/09 Comp181 Midterm Examination, Fall 09 10 Name Surname: Number: 90 min. 18/11/09 Answer ALL off the following questions. 1.What does the term hardware refer to? a. The relative difficulty of programming

More information

C Programming Dr. Hasan Demirel

C Programming Dr. Hasan Demirel C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

More information

Introduction to Programming

Introduction to Programming Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

More information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Programming in C: Basics CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of variable We must declare the

More information

Programming Fundamental. Instructor Name: Lecture-2

Programming Fundamental. Instructor Name: Lecture-2 Programming Fundamental Instructor Name: Lecture-2 Today s Lecture What is Programming? First C++ Program Programming Errors Variables in C++ Primitive Data Types in C++ Operators in C++ Operators Precedence

More information

6.096 Lab 1. Due: 7 January 12:30:00. September 20, 2011

6.096 Lab 1. Due: 7 January 12:30:00. September 20, 2011 6.096 Lab 1 Due: 7 January 1:30:00 September 0, 011 1 Additional Material 1.1 Constants A constant is an expressions with a fixed value. Kinds of constants: Literals: used to express particular values

More information

Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. ==

Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. == Group 1 Question 1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value. Question 2. What is the only

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

C programming. Intro to syntax & basic operations

C programming. Intro to syntax & basic operations C programming Intro to syntax & basic operations Example 1: simple calculation with I/O Program, line by line Line 1: preprocessor directive; used to incorporate code from existing library not actually

More information

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 4: Control Structures I (Selection)

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 4: Control Structures I (Selection) C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 4: Control Structures I (Selection) Objectives In this chapter, you will: Learn about control structures Examine relational

More information

Solution Exercise 1.1

Solution Exercise 1.1 Solution Exercise 1.1 Part I Fill in the blanks with the most appropriate answers. 1. A Program is a sequence of step-by-step instructions that a computer executes in order to solve a problem or to perform

More information

Part IA Computing Course Tutorial Guide to C++ Programming

Part IA Computing Course Tutorial Guide to C++ Programming Part IA Computing Course Tutorial Guide to C++ Programming Roberto Cipolla Department of Engineering University of Cambridge September 1, 2004 This document provides an introduction to computing and the

More information

Primitive Data Types Summer 2010 Margaret Reid-Miller

Primitive Data Types Summer 2010 Margaret Reid-Miller Primitive Data Types 15-110 Summer 2010 Margaret Reid-Miller Data Types Data stored in memory is a string of bits (0 or 1). What does 1000010 mean? 66? 'B'? 9.2E-44? How the computer interprets the string

More information

Tutorial-3a: First steps with C++ programming

Tutorial-3a: First steps with C++ programming HTTP://WWW.HEP.LU.SE/COURSES/MNXB01 Introduction to Programming and Computing for Scientists (2015 HT) Tutorial-3a: First steps with C++ programming Programming for Scientists Tutorial 3a 1 / 17 Quick

More information

Introduction to C++ Programming

Introduction to C++ Programming 2 Introduction to C++ Programming OBJECTIVES In this chapter you will learn: To write simple computer programs in C++. To write simple input and output statements. To use fundamental types. Basic computer

More information

Going from Python to C

Going from Python to C Going from Python to C Darin Brezeale December 8, 2011 Python is a high-level, interpreted language. C has many of the same types of programming constructs as in Python: arrays, loops, conditionals, functions,

More information

GETTING STARTED WITH C++ C++ BASICS - 1 -

GETTING STARTED WITH C++ C++ BASICS - 1 - - 1 - GETTING STARTED WITH C++ Programming is a core activity in the process of performing tasks or solving problems with the aid of a computer. An idealised picture is: PROBLEM COMPUTER SOLUTION Unfortunately

More information

Introduction to C++ Programming

Introduction to C++ Programming cpphtp5_02.fm Page 36 Wednesday, December 15, 2004 11:11 AM 2 Introduction to C++ Programming OBJECTIVES In this chapter you will learn: To write simple computer programs in C++. To write simple input

More information

Tutorial 9 Income Tax Calculator Application: Introducing the switch Multiple-Selection Statement

Tutorial 9 Income Tax Calculator Application: Introducing the switch Multiple-Selection Statement Tutorial 9 Income Tax Calculator Application: Introducing the switch Multiple-Selection Statement Outline 9.1 Test-Driving the Income Tax Calculator Application 9.2 Introducing the switch Multiple-Selection

More information

Lecture 1 Notes: Introduction

Lecture 1 Notes: Introduction Introduction to C++ January 4, 2011 Massachusetts Institute of Technology 6.096 Lecture 1 Notes: Introduction 1 Compiled Languages and C++ 1.1 Why Use a Language Like C++? At its core, a computer is just

More information

The Fundamentals of C++

The Fundamentals of C++ The Fundamentals of C++ Basic programming elements and concepts JPC and JWD 2002 McGraw-Hill, Inc. Program Organization Program statement Definition Declaration Action Executable unit Named set of program

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Chapter 5. Selection 5-1

Chapter 5. Selection 5-1 Chapter 5 Selection 5-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

CS101 Computer programming and utilization

CS101 Computer programming and utilization CS101 Computer programming and utilization Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building IIT Bombay Lecture 3, Basic features of C++ Tuesday, 2 August 2011

More information

Borland C++ Compiler: Operators

Borland C++ Compiler: Operators Introduction Borland C++ Compiler: Operators An operator is a symbol that specifies which operation to perform in a statement or expression. An operand is one of the inputs of an operator. For example,

More information

C++ Language Tutorial

C++ Language Tutorial cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain

More information

JavaScript: Control Statements I

JavaScript: Control Statements I 1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

More information

Chapter 4 Intro to Programming in C++

Chapter 4 Intro to Programming in C++ Chapter 4 Intro to Programming in C++ 4-1 Computer Programming Earlier we defined an algorithm to be a step by step process for solving a problem. Computer programming is the process of implementing the

More information

School of Informatics, University of Edinburgh

School of Informatics, University of Edinburgh CS1Ah Lecture Note 5 Java Expressions Many Java statements can contain expressions, which are program phrases that tell how to compute a data value. Expressions can involve arithmetic calculation and method

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

Lecture Set 2: Starting Java

Lecture Set 2: Starting Java Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables CMSC 131 - Lecture Outlines - set

More information

C++ Basics. C++ Basics: Names: Identifiers. Names: Identifiers. Display 2.1 A C++ Program (1 of 2) Display 2.1 A C++ Program (2 of 2)

C++ Basics. C++ Basics: Names: Identifiers. Names: Identifiers. Display 2.1 A C++ Program (1 of 2) Display 2.1 A C++ Program (2 of 2) C++ Basics C++ Basics: 2.1 Variables and Assignments Variables and Assignments Input and Output Data Types and Expressions Simple Flow of Control Program Style A C++ variable can hold a number or other

More information

UNIT-1. C Programming & Data Structures. Introduction to Computers: Computing Environment: Types of Computing Environments:

UNIT-1. C Programming & Data Structures. Introduction to Computers: Computing Environment: Types of Computing Environments: Introduction to Computers: C Programming & Data Structures UNIT-1 A computer system consists of hardware and software. Computer hardware is the collection of physical elements that comprise a computer

More information

INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

More information

CLEVELAND INSTITUTE OF ELECTRONICS A FIRST BOOK OF ANSI C, FOURTH EDITION LESSONS 9201C TO 9210C

CLEVELAND INSTITUTE OF ELECTRONICS A FIRST BOOK OF ANSI C, FOURTH EDITION LESSONS 9201C TO 9210C CLEVELAND INSTITUTE OF ELECTRONICS A FIRST BOOK OF ANSI C, FOURTH EDITION LESSONS 9201C TO 9210C 0 Study Guide to accompany A First Book of ANSI C, Fourth Edition By Gary J. Bronson ISBN: 1418835560 ISBN

More information

INTRODUCTION TO FLOWCHARTING

INTRODUCTION TO FLOWCHARTING CHAPTER 1 INTRODUCTION TO FLOWCHARTING 1.0 Objectives 1.1 Introduction 1.2 Flowcharts 1.3 Types of Flowcharts 1.3.1 Types of flowchart 1.3.2 System flowcharts 1.4 Flowchart Symbols 1.5 Advantages of Flowcharts

More information

()A Crash Course in Programming with C++ and the Ubuntu O.S. June 8, / 47

()A Crash Course in Programming with C++ and the Ubuntu O.S. June 8, / 47 A Crash Course in Programming with C++ and the Ubuntu O.S. Dr. Daniel A. Ray MCS Dept UVa-Wise June 8, 2010 ()A Crash Course in Programming with C++ and the Ubuntu O.S. June 8, 2010 1 / 47 Outline What

More information

Access Tutorial 12: An Introduction to Visual Basic

Access Tutorial 12: An Introduction to Visual Basic Access Tutorial 12: An Introduction to Visual Basic 12.1 Introduction: Learning the basics of programming Programming can be an enormously complex and difficult activity. Or it can be quite straightforward.

More information

Programming Language: Syntax. Introduction to C Language Overview, variables, Operators, Statements

Programming Language: Syntax. Introduction to C Language Overview, variables, Operators, Statements Programming Language: Syntax Introduction to C Language Overview, variables, Operators, Statements Based on slides McGraw-Hill Additional material 2004/2005 Lewis/Martin Modified by Diana Palsetia Syntax

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Outline TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA. What is DrJava? Dr Java

Outline TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA. What is DrJava? Dr Java 1 Outline TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

1. A(n) structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d.

1. A(n) structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d. Chapter Four MULTIPLE CHOICE 1. A(n) structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d. iteration 2. The decision structure

More information

Chapter 8. Arithmetic in C++

Chapter 8. Arithmetic in C++ Christian Jacob Chapter 8 Arithmetic in C++ 8.1 The C++ Vocabulary 8.2 Variables and Types 8.2.1 Data Objects 8.2.2 Variables 8.2.3 Declaration of Variables 8.3 Elementary C++ Data Types 8.3.1 Integers

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Computers process data under the control of sets of instructions called computer programs.

Computers process data under the control of sets of instructions called computer programs. Introduction Computer is a device capable of performing computations and making logical decisions at speeds millions and even billions of times faster than human beings. Computers process data under the

More information

Lecture 2 Notes: Flow of Control

Lecture 2 Notes: Flow of Control 6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The

More information

Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam

Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam Final Exam Review CS 1428 Fall 2011 Jill Seaman 1 Final Exam Friday, December 9, 11:00am to 1:30pm Derr 241 (here) Closed book, closed notes, clean desk Comprehensive (covers entire course) 25% of your

More information

Java Review (Essentials of Java for Hadoop)

Java Review (Essentials of Java for Hadoop) Java Review (Essentials of Java for Hadoop) Have You Joined Our LinkedIn Group? What is Java? Java JRE - Java is not just a programming language but it is a complete platform for object oriented programming.

More information

Pointers and Strings. Objectives

Pointers and Strings. Objectives 5 Pointers and Strings Objectives To be able to use pointers. To be able to use pointers to pass arguments to functions by reference. To understand the close relationships among pointers, arrays and strings.

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE

BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE Certificate in Advanced Programming - C++ Language Page 1 of 7 BHARATHIAR UNIVERSITY: COIMBATORE 641046 CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++

More information

Chapter 8 Selection 8-1

Chapter 8 Selection 8-1 Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Today s topics. Java programs. Java Virtual Machine (JVM) Bytecodes. HelloWorld.java javac HelloWorld.class

Today s topics. Java programs. Java Virtual Machine (JVM) Bytecodes. HelloWorld.java javac HelloWorld.class Today s topics Java programs Parsing Java Programming Notes from Tammy Bailey Reading Great Ideas, Chapter 3 & 4 Java programs are created as text files using a text editor (like emacs) Save to disk with.java

More information

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

More information

CHAPTER 2 PROBLEM SOLVING

CHAPTER 2 PROBLEM SOLVING CHAPTER 2 PROBLEM SOLVING This chapter will cover the following topics: Problem Solving Concepts for the Computer Pre-Programming Phase Programming Or Implementation Phase What Problem Can Be Solved By

More information

Reading Assignment. Main Program in C. K.N. King Chapter 2. K.N. King Chapter 3. K.N. King Chapter 4. K.N. King Chapter 7. Our first C program

Reading Assignment. Main Program in C. K.N. King Chapter 2. K.N. King Chapter 3. K.N. King Chapter 4. K.N. King Chapter 7. Our first C program Reading Assignment Main Program in C In C the main program is a function called main The body of the function is enclosed in left ( ) and right ( ) curly braces. K.N. King Chapter 2 K.N. King Chapter 3

More information

OBJECT ORIENTED PROGRAMMING IN C++

OBJECT ORIENTED PROGRAMMING IN C++ OBJECT ORIENTED PROGRAMMING IN C++ For Off Campus BSc Computer Science Programme UNIT 1 1. The goal of programmers is to develop software that are. A. Correct B. Reliable and maintainable C. Satisfy all

More information

PL / SQL Basics. Chapter 3

PL / SQL Basics. Chapter 3 PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic

More information

Common Syntax and Semantic Errors

Common Syntax and Semantic Errors C H A P T E R 2 Common Syntax and Semantic Errors 2.1 CHAPTER OBJECTIVES To understand the fundamental characteristics of syntax and semantic errors To be able to identify specific common syntax and semantic

More information

PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode?

PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode? PE1 Worksheet Problem solving 1) What are the four stages of problem solving by programming? What shall be done in each stage? Stage 1: Stage 2: Stage 3: Stage 4: 2) What is the top-down design strategy

More information

Input and Output! Objectives" (and predefined functions)" 1E3! Topic 4! n Learn what a stream is and examine input and output streams!

Input and Output! Objectives (and predefined functions) 1E3! Topic 4! n Learn what a stream is and examine input and output streams! Input and Output! (and predefined functions)" 1E3! Topic 4! 4 I/O 1 Objectives" n Learn what a stream is and examine input and output streams! n Explore how to read data from the standard input device!

More information

Moving from C++ to VBA

Moving from C++ to VBA Introduction College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 309 Numerical Analysis of Engineering Systems Fall 2014 Number: 15237 Instructor: Larry

More information

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering Cohort: BCNS/07/FT- BIS/07/FT- BIS/06/FT -BM/07/FT BSE/07/FT/PT-

More information

PROGRAMMING REFRESHER MODULE. Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot

PROGRAMMING REFRESHER MODULE. Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot PROGRAMMING REFRESHER MODULE Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot The Rules Everything in PREF (Week 1) is optional. From week 2 of APRC and JAPC, we assume that all

More information

Question 2. Question 3. 0 out of 1 points. The basic commands that a computer performs are, and performance of arithmetic and logical operations.

Question 2. Question 3. 0 out of 1 points. The basic commands that a computer performs are, and performance of arithmetic and logical operations. The basic commands that a computer performs are, and performance of arithmetic and logical operations. input, file Question 2 input, output, storage output, folder storage, directory Main memory is called.

More information

Introduction to Classes and Objects

Introduction to Classes and Objects 3 Introduction to Classes and Objects OBJECTIVES In this chapter you will learn: What classes, objects, member functions and data members are. How to define a class and use it to create an object. How

More information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements 9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

More information

A Comparison of the Basic Syntax of Python and Java

A Comparison of the Basic Syntax of Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

C A short introduction

C A short introduction About these lectures C A short introduction Stefan Johansson Department of Computing Science Umeå University Objectives Give a short introduction to C and the C programming environment in Linux/Unix Go

More information

Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1

Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1 Computer Programming Programming Language Is telling the computer how to do something Wikipedia Definition: Applies specific programming languages to solve specific computational problems with solutions

More information

conditional statements

conditional statements L E S S O N S E T 4 Conditional Statements PU RPOSE PROCE DU RE 1. To work with relational operators 2. To work with conditional statements 3. To learn and use nested if statements 4. To learn and use

More information

Engineering Problem Solving with C++, Etter/Ingber

Engineering Problem Solving with C++, Etter/Ingber Engineering Problem Solving with C++, Etter/Ingber Chapter 3 Control Structures 1 Control structures Algorithm Development Conditional Expressions Selection Statements Repetition Statements Structuring

More information

Introduction to Programming (in C++) Data types and visibility. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. Computer Science, UPC

Introduction to Programming (in C++) Data types and visibility. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. Computer Science, UPC Introduction to Programming (in C++) Data types and visibility Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. Computer Science, UPC Outline Data types Type conversion Visibility Introduction to

More information

13 Classes & Objects with Constructors/Destructors

13 Classes & Objects with Constructors/Destructors 13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.

More information

defino_433130_ttl.qxd 3/2/06 10:56 AM Page 1 LAB MANUAL to Accompany Dean DeFino Salisbury University Michael Bardzell Salisbury University

defino_433130_ttl.qxd 3/2/06 10:56 AM Page 1 LAB MANUAL to Accompany Dean DeFino Salisbury University Michael Bardzell Salisbury University defino_433130_ttl.qxd 3/2/06 10:56 AM Page 1 LAB MANUAL to Accompany Dean DeFino Salisbury University Michael Bardzell Salisbury University defino_433130_ttl.qxd 3/2/06 10:56 AM Page 2 Executive Editor

More information

Appendix K Introduction to Microsoft Visual C++ 6.0

Appendix K Introduction to Microsoft Visual C++ 6.0 Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

More information

Branching. We ll continue to look at the basics of writing C++ programs including. Overview

Branching. We ll continue to look at the basics of writing C++ programs including. Overview Branching Overview We ll continue to look at the basics of writing C++ programs including Boolean Expressions (need to know this before we can using branching and looping!) Branching J.S. Bradbury CSCI

More information

Boolean Variables and Expressions

Boolean Variables and Expressions Boolean Variables and Expressions 1 Recall Standard C++ supports a simple data type specialized for representing logical values. bool type variables can have either of two values: or The identifiers and

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information