Scientific Computing

Size: px
Start display at page:

Download "Scientific Computing"

Transcription

1 Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014

2 Outline Course Overview Programming Basics The C++ Programming Language

3 Outline Course Overview Programming Basics The C++ Programming Language

4 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 1 / 26

5 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: 1 / 26

6 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables 1 / 26

7 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output 1 / 26

8 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control 1 / 26

9 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control Functions 1 / 26

10 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control Functions Dynamic allocation and pointers 1 / 26

11 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control Functions Dynamic allocation and pointers Using standard libraries 1 / 26

12 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control Functions Dynamic allocation and pointers Using standard libraries Object-Orientated Programming (OOP) 1 / 26

13 Overview of the course This course gives a practical introduction to programming using C++ as programming language. 5 weeks of lectures and tutorials include: Data and variables Input and output Flow control Functions Dynamic allocation and pointers Using standard libraries Object-Orientated Programming (OOP) Debugging and test-based development 1 / 26

14 Course objectives By the end of the course you will be able to: Understand the basic concepts of programming Convert mathematical algorithms into C++ code Interpret the output from a program, producing figures and/or tables to show results Use the concepts of Object-Orientated Programming to improve your programs Implement a numerical method and write a technical report on it 2 / 26

15 Lecture 1 Topics of the first lecture: Computers and programs Syntax and structure of a C++ program Data and variables 3 / 26

16 Lecture 1 Topics of the first lecture: Computers and programs Syntax and structure of a C++ program Data and variables At the end of the lecture you should: Understand the idea of programming a computer Write a simple program to input and output data 3 / 26

17 Outline Course Overview Programming Basics The C++ Programming Language

18 Computers What is a computer? A computer is a device that carries out a series of instructions in order to solve problems. Memory Input CPU Output File Storage An idealised computer 4 / 26

19 Computers What is a computer? A computer is a device that carries out a series of instructions in order to solve problems. Memory CPU - Central Processing Unit Input CPU Output File Storage An idealised computer 4 / 26

20 Computers What is a computer? A computer is a device that carries out a series of instructions in order to solve problems. Memory CPU - Central Processing Unit Input CPU Output CPU and memory work together File Storage An idealised computer 4 / 26

21 Computers What is a computer? A computer is a device that carries out a series of instructions in order to solve problems. Memory CPU - Central Processing Unit Input CPU Output CPU and memory work together File Storage Input may be from keyboard, mouse or a file An idealised computer 4 / 26

22 Computers What is a computer? A computer is a device that carries out a series of instructions in order to solve problems. Memory Input CPU Output File Storage An idealised computer CPU - Central Processing Unit CPU and memory work together Input may be from keyboard, mouse or a file Output may be to screen or a file 4 / 26

23 Some history: The Baby The world s first stored-program computer, the Small Scale Experimental Machine (SSEM), also called The Baby, was developed at Manchester University in (Picture credit: MOSI) 5 / 26

24 Programming What is a computer program? A program is sequence of step-by-step instructions that enable a computer to complete a task. 6 / 26

25 Programming What is a computer program? A program is sequence of step-by-step instructions that enable a computer to complete a task. A computer program is a concrete implementation of an algorithm on a computer. 6 / 26

26 Programming What is a computer program? A program is sequence of step-by-step instructions that enable a computer to complete a task. A computer program is a concrete implementation of an algorithm on a computer. A computer program can be in computer-readable executable form, or human-readable source code form. 6 / 26

27 Programming What is a computer program? A program is sequence of step-by-step instructions that enable a computer to complete a task. A computer program is a concrete implementation of an algorithm on a computer. A computer program can be in computer-readable executable form, or human-readable source code form. The process of translating source code to executable code is called compilation. 6 / 26

28 Programming What is a computer program? A program is sequence of step-by-step instructions that enable a computer to complete a task. A computer program is a concrete implementation of an algorithm on a computer. A computer program can be in computer-readable executable form, or human-readable source code form. The process of translating source code to executable code is called compilation. Programming is understanding Since computers do exactly as they are being told, successfully programming them to solve a problem requires spending considerable time in understanding the problem first. 6 / 26

29 Programming: an example Example Euclid s algorithm finds the greatest common divisor of two integers. Input a, b b = 0? no a > b? yes Output a a a b yes no b b a #include <iostream> using namespace std; int main() { int a,b; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; while(b!=0) { if (a>b) a = a-b; else b = b-a; } cout << "The gcd of a and b is: " << a << endl; } Euclid s algorithm as flowchart and as C++ source code. 7 / 26

30 Programming: the good old days #include <iostream> using namespace std; int main() { int a,b; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; while(b!=0) { if (a>b) a = a-b; else b = b-a; } cout << "The gcd of a and b is: " << a << endl; } A FORTRAN punch card vs. C++ source code. 8 / 26

31 Programming: the good old days Alan Turing not only developed the mathematical foundations of programming, he also wrote the first computer program to play chess. 9 / 26

32 Programming languages 10 / 26

33 Programming languages The source code of a computer program is written in one of many programming languages. 10 / 26

34 Programming languages The source code of a computer program is written in one of many programming languages. Examples of programming languages include Fortran, Fortran 95 C, C++, C# Java, JavaScript Python 10 / 26

35 Programming languages The source code of a computer program is written in one of many programming languages. Examples of programming languages include Fortran, Fortran 95 C, C++, C# Java, JavaScript Python Different languages were designed and optimised for different purposes. 10 / 26

36 Programming languages The source code of a computer program is written in one of many programming languages. Examples of programming languages include Fortran, Fortran 95 C, C++, C# Java, JavaScript Python Different languages were designed and optimised for different purposes. The basic principles of programming are independent of the particular language chosen. Understanding one language makes it easy to learn others! 10 / 26

37 Outline Course Overview Programming Basics The C++ Programming Language

38 The C++ programming language 11 / 26

39 The C++ programming language Developed in the 1980s by Bjarne Stroustrup as object-oriented extension to C. 11 / 26

40 The C++ programming language Developed in the 1980s by Bjarne Stroustrup as object-oriented extension to C. A powerful, multi-purpose, medium-level programming language. 11 / 26

41 The C++ programming language Developed in the 1980s by Bjarne Stroustrup as object-oriented extension to C. A powerful, multi-purpose, medium-level programming language. Used virtually everywhere: from the implementation of operating systems (Windows, Unix, MacOS/OS X) to most big applications. 11 / 26

42 Creating a C++ program 12 / 26

43 Creating a C++ program Code is saved as a text file and written using an editor. 12 / 26

44 Creating a C++ program Code is saved as a text file and written using an editor. The code is then compiled into an executable file. On Unix systems, for example, c++ euclid.cpp -o euclid means that the source code in the file euclid.cpp is transformed into the executable file euclid. 12 / 26

45 Creating a C++ program Code is saved as a text file and written using an editor. The code is then compiled into an executable file. On Unix systems, for example, c++ euclid.cpp -o euclid means that the source code in the file euclid.cpp is transformed into the executable file euclid. In this course we will encourage the use of an Integrated Development Environment (IDE). 12 / 26

46 Creating a C++ program Code is saved as a text file and written using an editor. The code is then compiled into an executable file. On Unix systems, for example, c++ euclid.cpp -o euclid means that the source code in the file euclid.cpp is transformed into the executable file euclid. In this course we will encourage the use of an Integrated Development Environment (IDE). Three recommended pieces of software are: Visual Studio (Windows only) Netbeans (Windows/Linux/Mac) Eclipse (Linux KDE) 12 / 26

47 Creating a C++ program Code is saved as a text file and written using an editor. The code is then compiled into an executable file. On Unix systems, for example, c++ euclid.cpp -o euclid means that the source code in the file euclid.cpp is transformed into the executable file euclid. In this course we will encourage the use of an Integrated Development Environment (IDE). Three recommended pieces of software are: Visual Studio (Windows only) Netbeans (Windows/Linux/Mac) Eclipse (Linux KDE) For the purposes of this course, it will not matter on which platform you write the code. 12 / 26

48 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: 13 / 26

49 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: Semicolon used to mark end of statements 13 / 26

50 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: Semicolon used to mark end of statements Case is important 13 / 26

51 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: Semicolon used to mark end of statements Case is important Totally free form, lines and names can be as long as you like! 13 / 26

52 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: Semicolon used to mark end of statements Case is important Totally free form, lines and names can be as long as you like! Comments take the form /* C style comment */ or // C++ style comment 13 / 26

53 C++ Syntax C++ source code consists of a sequence of instruction. The key elements of C/C++ syntax are: Semicolon used to mark end of statements Case is important Totally free form, lines and names can be as long as you like! Comments take the form /* C style comment */ or // C++ style comment Code blocks are surrounded by braces {} 13 / 26

54 C++ Structure #include <iostream> using namespace std; int main() { int a,b,c; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; c = a+b; // Compute sum of two numbers cout << "The sum of a and b is: " << c << endl; } 14 / 26

55 C++ Structure #include <iostream> using namespace std; Include libraries int main() { int a,b,c; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; c = a+b; // Compute sum of two numbers cout << "The sum of a and b is: " << c << endl; } 14 / 26

56 C++ Structure #include <iostream> using namespace std; int main() { int a,b,c; Include libraries Declare data types and variable names cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; c = a+b; // Compute sum of two numbers cout << "The sum of a and b is: " << c << endl; } 14 / 26

57 C++ Structure #include <iostream> using namespace std; int main() { int a,b,c; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; Include libraries Declare data types and variable names Input values for variables c = a+b; // Compute sum of two numbers cout << "The sum of a and b is: " << c << endl; } 14 / 26

58 C++ Structure #include <iostream> using namespace std; int main() { int a,b,c; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; c = a+b; // Compute sum of two numbers Include libraries Declare data types and variable names Input values for variables Calculations are carried out in sequence cout << "The sum of a and b is: " << c << endl; } 14 / 26

59 C++ Structure #include <iostream> using namespace std; int main() { int a,b,c; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; c = a+b; // Compute sum of two numbers cout << "The sum of a and b is: " << c << endl; } Include libraries Declare data types and variable names Input values for variables Calculations are carried out in sequence Output to the screen or a file 14 / 26

60 Libraries #include <iostream> / 26

61 Libraries #include <iostream>... Unlike higher level programming languages, there are almost no intrinsic functions in C++. This includes the ability to print to screen. 15 / 26

62 Libraries #include <iostream>... Unlike higher level programming languages, there are almost no intrinsic functions in C++. This includes the ability to print to screen. We can include standard libraries for: Input/Output Advanced storage Strings Mathematical functions 15 / 26

63 Libraries #include <iostream>... Unlike higher level programming languages, there are almost no intrinsic functions in C++. This includes the ability to print to screen. We can include standard libraries for: Input/Output Advanced storage Strings Mathematical functions The syntax is: #include <library name > 15 / 26

64 Libraries #include <iostream>... Unlike higher level programming languages, there are almost no intrinsic functions in C++. This includes the ability to print to screen. We can include standard libraries for: Input/Output Advanced storage Strings Mathematical functions The syntax is: #include <library name > Include statements must appear before any other statements. 15 / 26

65 Data and variables... int a,b,c; / 26

66 Data and variables... int a,b,c;... One of the most common mistakes when programming is caused by swapping between data types (for example, integers and floating point numbers) 16 / 26

67 Data and variables... int a,b,c;... One of the most common mistakes when programming is caused by swapping between data types (for example, integers and floating point numbers) Program may not work quite how we want / 26

68 Data and variables... int a,b,c;... One of the most common mistakes when programming is caused by swapping between data types (for example, integers and floating point numbers) Program may not work quite how we want... So we must understand how the computer uses data. 16 / 26

69 Standard data types 17 / 26

70 Standard data types There are six basic data types in C++: char a character (short/long) int integers with different sizes float single precision real number (long) double double (or higher) precision number bool true or false binary number void this is used when a function doesn t return a value 17 / 26

71 Standard data types There are six basic data types in C++: char a character (short/long) int integers with different sizes float single precision real number (long) double double (or higher) precision number bool true or false binary number void this is used when a function doesn t return a value The precision of numbers will effect the maximum and minimum values they can take 17 / 26

72 Standard data types There are six basic data types in C++: char a character (short/long) int integers with different sizes float single precision real number (long) double double (or higher) precision number bool true or false binary number void this is used when a function doesn t return a value The precision of numbers will effect the maximum and minimum values they can take and also how big errors are. 17 / 26

73 Declaring variables 18 / 26

74 Declaring variables A variable is a named location in memory, used to store data. 18 / 26

75 Declaring variables A variable is a named location in memory, used to store data. We may declare variables anywhere in the code. 18 / 26

76 Declaring variables A variable is a named location in memory, used to store data. We may declare variables anywhere in the code. Variables will be localised to the block in which they are declared 18 / 26

77 Declaring variables A variable is a named location in memory, used to store data. We may declare variables anywhere in the code. Variables will be localised to the block in which they are declared What is the output from the following? int i=0; cout << " i= " << i << endl; { int i=10; cout << " i= " << i << endl; } cout << " i= " << i << endl; 18 / 26

78 Namespaces... using namespace std; / 26

79 Namespaces... using namespace std;... Each variable requires a unique name (in the same scope) 19 / 26

80 Namespaces... using namespace std;... Each variable requires a unique name (in the same scope) In large projects this becomes very difficult 19 / 26

81 Namespaces... using namespace std;... Each variable requires a unique name (in the same scope) In large projects this becomes very difficult A namespace is like adding a surname to a variable: For example, we would have to write std::cout << "Hello World!" << endl; to indicate that the name cout is to be taken from the standard librarystd. 19 / 26

82 Namespaces... using namespace std;... Each variable requires a unique name (in the same scope) In large projects this becomes very difficult A namespace is like adding a surname to a variable: For example, we would have to write std::cout << "Hello World!" << endl; to indicate that the name cout is to be taken from the standard librarystd. The using namespace std; statement at the beginning saves us the hassle of having to use the surname every time we call someone from the std family. 19 / 26

83 Simple input and output 20 / 26

84 Simple input and output We use stream variables to access the screen, keyboard and files. 20 / 26

85 Simple input and output We use stream variables to access the screen, keyboard and files. They allow us to associate a name with a physical output. 20 / 26

86 Simple input and output We use stream variables to access the screen, keyboard and files. They allow us to associate a name with a physical output. We need to include stream libraries at the top of the program #include<iostream> using namespace std main() { int i; cout << " Enter a number. " << endl; cin >> i; //read in a number cout << " Your number is " << i << endl; } 20 / 26

87 Simple input and output 21 / 26

88 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable 21 / 26

89 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable To pass data to and from the stream we use the << and >> operators. 21 / 26

90 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable To pass data to and from the stream we use the << and >> operators. << data is passed right to left, in the example the string is passed to cout 21 / 26

91 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable To pass data to and from the stream we use the << and >> operators. << data is passed right to left, in the example the string is passed to cout >> data is passed left to right, in the example the integer is passed from cin to i 21 / 26

92 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable To pass data to and from the stream we use the << and >> operators. << data is passed right to left, in the example the string is passed to cout >> data is passed left to right, in the example the integer is passed from cin to i Multiple bits of data can be passed to the stream by stringing them together in the same command. 21 / 26

93 Simple input and output cout is the standard screen variable, and cin the standard keyboard variable To pass data to and from the stream we use the << and >> operators. << data is passed right to left, in the example the string is passed to cout >> data is passed left to right, in the example the integer is passed from cin to i Multiple bits of data can be passed to the stream by stringing them together in the same command. Use endl to finish a line. 21 / 26

94 Using variables 22 / 26

95 Using variables We can assign a variable a value using = data 1 = / 26

96 Using variables We can assign a variable a value using = data 1 = The data types on both sides of = must be compatible 22 / 26

97 Using variables We can assign a variable a value using = data 1 = The data types on both sides of = must be compatible We can add/subtract, multiply/divide standard data types double a,b,c; b = 5. ; c = 4.1; a = 10. * b + c; 22 / 26

98 Other operators 23 / 26

99 Other operators We call +-*/ operators 23 / 26

100 Other operators We call +-*/ operators We shall see later that they may be overloaded. 23 / 26

101 Other operators We call +-*/ operators We shall see later that they may be overloaded. Other operators are: a%b :: returns a modulus b a++ :: increment a by 1 a-- :: decrement a by 1 a+=b :: set a equal to a plus b a*=b :: set a equal to a times b 23 / 26

102 An example program #include <iostream> using namespace std; int main() { int a; cout << "Enter a number: "; cin >> a; a*=a; cout << "The square is " << a << endl; } 24 / 26

103 An example program #include <iostream> using namespace std; int main() { int a; cout << "Enter a number: "; cin >> a; a*=a; cout << "The square is " << a << endl; } If this program is contained in square.cpp, then under Unix we can do: 24 / 26

104 An example program #include <iostream> using namespace std; int main() { int a; cout << "Enter a number: "; cin >> a; a*=a; cout << "The square is " << a << endl; } If this program is contained in square.cpp, then under Unix we can do: % c++ square.cpp -o square %./square Enter a number: 5 The square is / 26

105 File input and output 25 / 26

106 File input and output To read and write to files we must include the fstream library. 25 / 26

107 File input and output To read and write to files we must include the fstream library. Input streams have type ifstream, and output streams ofstream ifstream file input; // an input file stream ofstream file output; // an output file stream 25 / 26

108 File input and output To read and write to files we must include the fstream library. Input streams have type ifstream, and output streams ofstream ifstream file input; // an input file stream ofstream file output; // an output file stream ifstream and ofstream have intrinsic functions to open and close files. 25 / 26

109 File input and output To read and write to files we must include the fstream library. Input streams have type ifstream, and output streams ofstream ifstream file input; // an input file stream ofstream file output; // an output file stream ifstream and ofstream have intrinsic functions to open and close files. We can also check if the file is open with the is open() function. file input.open("input.in"); // open file input.in if(file input.is open()) // check file is open 25 / 26

110 Summary 26 / 26

111 Summary Topics: Computers and programs Fundamentals of C++ Data and variables Input and output 26 / 26

112 Summary Topics: Computers and programs Fundamentals of C++ Data and variables Input and output Aims: Understand the idea of programming a computer Write a simple program to input and output data, and perform basic arithmetic operations 26 / 26

C++ Support Classes (Data and Variables)

C++ Support Classes (Data and Variables) C++ Support Classes (Data and Variables) School of Mathematics 2018 Today s lecture Topics: Computers and Programs; Syntax and Structure of a Program; Data and Variables; Aims: Understand the idea of programming

More information

A SHORT COURSE ON C++

A SHORT COURSE ON C++ Introduction to A SHORT COURSE ON School of Mathematics Semester 1 2008 Introduction to OUTLINE 1 INTRODUCTION TO 2 FLOW CONTROL AND FUNCTIONS If Else Looping Functions Cmath Library Prototyping Introduction

More information

Chapter 1 INTRODUCTION

Chapter 1 INTRODUCTION Chapter 1 INTRODUCTION A digital computer system consists of hardware and software: The hardware consists of the physical components of the system. The software is the collection of programs that a computer

More information

2 nd Week Lecture Notes

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

More information

Computer Programming : C++

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

More information

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language

More information

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers and C++ Programming Chapter 1 Introduction to Computers and C++ Programming 1 Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.7 History of C and C++ 1.14 Basics of a Typical C++ Environment 1.20

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

Welcome to MCS 360. content expectations. using g++ input and output streams the namespace std. Euclid s algorithm the while and do-while statements

Welcome to MCS 360. content expectations. using g++ input and output streams the namespace std. Euclid s algorithm the while and do-while statements Welcome to MCS 360 1 About the Course content expectations 2 our first C++ program using g++ input and output streams the namespace std 3 Greatest Common Divisor Euclid s algorithm the while and do-while

More information

Introduction to Programming using C++

Introduction to Programming using C++ Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know

More information

C++ for Python Programmers

C++ for Python Programmers C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers

More information

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

Tutorial-2a: First steps with C++ programming Programming for Scientists Tutorial 2a 1 / 18 HTTP://WWW.HEP.LU.SE/COURSES/MNXB01 Introduction to Programming and Computing for Scientists Tutorial-2a: First steps with C++ programming Programming for

More information

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

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

More information

Introduction to C ++

Introduction to C ++ Introduction to C ++ Thomas Branch tcb06@ic.ac.uk Imperial College Software Society October 18, 2012 1 / 48 Buy Software Soc. s Free Membership at https://www.imperialcollegeunion.org/shop/ club-society-project-products/software-products/436/

More information

EP241 Computer Programming

EP241 Computer Programming EP241 Computer Programming Topic 1 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department of Electric and Electronics Engineering Sep

More information

COMP322 - Introduction to C++ Lecture 01 - Introduction

COMP322 - Introduction to C++ Lecture 01 - Introduction COMP322 - Introduction to C++ Lecture 01 - Introduction Robert D. Vincent School of Computer Science 6 January 2010 What this course is Crash course in C++ Only 14 lectures Single-credit course What this

More information

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3 Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions

More information

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++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More 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

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

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

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

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

More information

Chapter 1: Why Program? Computers and Programming. Why Program?

Chapter 1: Why Program? Computers and Programming. Why Program? Chapter 1: Introduction to Computers and Programming 1.1 Why Program? Why Program? Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something

More information

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

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. 1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format

More information

Introduction to C++ Introduction to C++ 1

Introduction to C++ Introduction to C++ 1 1 What Is C++? (Mostly) an extension of C to include: Classes Templates Inheritance and Multiple Inheritance Function and Operator Overloading New (and better) Standard Library References and Reference

More information

Partha Sarathi Mandal

Partha Sarathi Mandal MA 253: Data Structures Lab with OOP Tutorial 1 http://www.iitg.ernet.in/psm/indexing_ma253/y13/index.html Partha Sarathi Mandal psm@iitg.ernet.in Dept. of Mathematics, IIT Guwahati Reference Books Cormen,

More information

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 22, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers ords Data Types And Variable Declarations

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

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

More information

Understanding main() function Input/Output Streams

Understanding main() function Input/Output Streams Understanding main() function Input/Output Streams Structure of a program // my first program in C++ #include int main () { cout

More information

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program: Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams

More information

Your first C++ program

Your first C++ program Your first C++ program #include using namespace std; int main () cout

More information

Chapter 2: Overview of C++

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

More information

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

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

More information

Objectives. In this chapter, you will:

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

More information

C++_ MARKS 40 MIN

C++_ MARKS 40 MIN C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float

More information

Increment and the While. Class 15

Increment and the While. Class 15 Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment

More information

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

More information

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

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

More information

C++ For Science and Engineering Lecture 12

C++ For Science and Engineering Lecture 12 C++ For Science and Engineering Lecture 12 John Chrispell Tulane University Monday September 20, 2010 Comparing C-Style strings Note the following listing dosn t do what you probably think it does (assuming

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence

More information

Homework #3 CS2255 Fall 2012

Homework #3 CS2255 Fall 2012 Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation

More information

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program: Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams

More information

MA400: Financial Mathematics

MA400: Financial Mathematics MA400: Financial Mathematics Introductory Course Lecture 1: Overview of the course Preliminaries A brief introduction Beginning to program Some example programs Aims of this course Students should have

More information

Summary of basic C++-commands

Summary of basic C++-commands Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq CS 241 Computer Programming Introduction Teacher Assistant Hadeel Al-Ateeq 1 2 Course URL: http://241cs.wordpress.com/ Hadeel Al-Ateeq 3 Textbook HOW TO PROGRAM BY C++ DEITEL AND DEITEL, Seventh edition.

More information

CS2255 HOMEWORK #1 Fall 2012

CS2255 HOMEWORK #1 Fall 2012 CS55 HOMEWORK #1 Fall 01 1.What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y; a. 10 b. 7 c. The

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

File Operations. Lecture 16 COP 3014 Spring April 18, 2018

File Operations. Lecture 16 COP 3014 Spring April 18, 2018 File Operations Lecture 16 COP 3014 Spring 2018 April 18, 2018 Input/Ouput to and from files File input and file output is an essential in programming. Most software involves more than keyboard input and

More information

C and C++ I. Spring 2014 Carola Wenk

C and C++ I. Spring 2014 Carola Wenk C and C++ I Spring 2014 Carola Wenk Different Languages Python sum = 0 i = 1 while (i

More information

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

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

More information

Input and Output File (Files and Stream )

Input and Output File (Files and Stream ) Input and Output File (Files and Stream ) BITE 1513 Computer Game Programming Week 14 Scope Describe the fundamentals of input & output files. Use data files for input & output purposes. Files Normally,

More information

LECTURE 02 INTRODUCTION TO C++

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

More information

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

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

More information

Chapter 2: Introduction to C++

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

More information

C++ Quick Guide. Advertisements

C++ Quick Guide. Advertisements C++ Quick Guide Advertisements Previous Page Next Page C++ is a statically typed, compiled, general purpose, case sensitive, free form programming language that supports procedural, object oriented, and

More information

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

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

More information

CS242 COMPUTER PROGRAMMING

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

More information

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

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

More information

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad Outline 1. Introduction to C++ Programming 2. Comment 3. Variables and Constants 4. Basic C++ Data Types 5. Simple Program: Printing

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

C++ basics Getting started with, and Data Types.

C++ basics Getting started with, and Data Types. C++ basics Getting started with, and Data Types pm_jat@daiict.ac.in Recap Last Lecture We talked about Variables - Variables, their binding to type, storage etc., Categorization based on storage binding

More information

C, C++, Fortran: Basics

C, C++, Fortran: Basics C, C++, Fortran: Basics Bruno Abreu Calfa Last Update: September 27, 2011 Table of Contents Outline Contents 1 Introduction and Requirements 1 2 Basic Programming Elements 2 3 Application: Numerical Linear

More information

C++ Programming for Non-C Programmers. Supplement

C++ Programming for Non-C Programmers. Supplement C++ Programming for Non-C Programmers Supplement ii C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by itcourseware, 10333 E. Dry Creek Rd., Suite 150, Englewood,

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 5 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

More information

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

! 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

More information

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

6.096 Introduction to C++ January (IAP) 2009

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

More information

UNIT- 3 Introduction to C++

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

More information

File I/O Christian Schumacher, Info1 D-MAVT 2013

File I/O Christian Schumacher, Info1 D-MAVT 2013 File I/O Christian Schumacher, chschuma@inf.ethz.ch Info1 D-MAVT 2013 Input and Output in C++ Stream objects Formatted output Writing and reading files References General Remarks I/O operations are essential

More information

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

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

A First Program - Greeting.cpp

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

More information

Introduction to C++ Lecture Set 2. Introduction to C++ Week 2 Dr Alex Martin 2013 Slide 1

Introduction to C++ Lecture Set 2. Introduction to C++ Week 2 Dr Alex Martin 2013 Slide 1 Introduction to C++ Lecture Set 2 Introduction to C++ Week 2 Dr Alex Martin 2013 Slide 1 More Arithmetic Operators More Arithmetic Operators In the first session the basic arithmetic operators were introduced.

More information

Chapter 2 C++ Fundamentals

Chapter 2 C++ Fundamentals Chapter 2 C++ Fundamentals 3rd Edition Computing Fundamentals with C++ Rick Mercer Franklin, Beedle & Associates Goals Reuse existing code in your programs with #include Obtain input data from the user

More information

Introduction to C ++

Introduction to C ++ Introduction to C ++ Thomas Branch tcb06@ic.ac.uk Imperial College Software Society November 15, 2012 1 / 63 Buy Software Soc. s Free Membership at https://www.imperialcollegeunion.org/shop/ club-society-project-products/software-products/436/

More information

Week 1: Hello World! Muhao Chen

Week 1: Hello World! Muhao Chen Week 1: Hello World! Muhao Chen 1 Muhao Chen Teaching Fellow Email address: muhaochen@ucla.edu Office Hours: Thursday 11:30 ~ 2:30 PM BH2432 Personal office BH3551 Homepage (where I post slides): http://yellowstone.cs.ucla.edu/~muhao/

More information

4. Structure of a C++ program

4. Structure of a C++ program 4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

Reading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary

Reading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary Reading from and Writing to Files Section 3.12 & 13.1 & 13.5 11/3/08 CS150 Introduction to Computer Science 1 1 Files (3.12) Data stored in variables is temporary We will learn how to write programs that

More information

Outline. 1 About the course

Outline. 1 About the course Outline EDAF50 C++ Programming 1. Introduction 1 About the course Sven Gestegård Robertz Computer Science, LTH 2018 2 Presentation of C++ History Introduction Data types and variables 1. Introduction 2/1

More information

Strings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Strings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Chapter 1: Introduction to Computers and Programming

Chapter 1: Introduction to Computers and Programming Chapter 1: Introduction to Computers and Programming 1.1 Why Program? Why Program? Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something

More information

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Introduction to C++ Programming. Adhi Harmoko S, M.Komp Introduction to C++ Programming Adhi Harmoko S, M.Komp Machine Languages, Assembly Languages, and High-level Languages Three types of programming languages Machine languages Strings of numbers giving machine

More information

a data type is Types

a data type is Types Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental

More information

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE a) Mention any 4 characteristic of the object car. Ans name, colour, model number, engine state, power b) What

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

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

More information

BITG 1113: Files and Stream LECTURE 10

BITG 1113: Files and Stream LECTURE 10 BITG 1113: Files and Stream LECTURE 10 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of input & output files. 2. Use data files for input & output

More information

Programming in C/C

Programming in C/C Programming in C/C++ 2004-2005 http://cs.vu.nl/~nsilvis/c++/2005 Natalia Silvis-Cividjian e-mail: nsilvis@few.vu.nl Topics about C++ language about this course C++ basics self test exercises (10 min) (10

More information

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam. Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 1 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

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

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)

More information

Introduction to C++ Systems Programming

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

More information

Text File I/O. #include <iostream> #include <fstream> using namespace std; int main() {

Text File I/O. #include <iostream> #include <fstream> using namespace std; int main() { Text File I/O We can use essentially the same techniques we ve been using to input from the keyboard and output to the screen and just apply them to files instead. If you want to prepare input data ahead,

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

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

More information

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

More information