Distributed Real-Time Control Systems. Chapter 4 Very Basics of C++
|
|
- Ashlee Watkins
- 5 years ago
- Views:
Transcription
1 Distributed Real-Time Control Systems Chapter 4 Very Basics of C++ 1
2 Bibliography Online Covers C
3 What is C++? A computer language with object oriented programming capabilities. Invented by Bjarne Stroustroup, at the AT&T Bell Labs in the early 80 s. Derived from C. Originally a C++ to C converter. Complements the C syntax with many new features to give more flexibility and improve compile time error checking. Most existing C code compiles in a C++ compiler with few adaptations. Compatible with most C libraries and development tools. 3
4 Why C++ for Real-Time Systems? Designed for run-time efficiency. Object oriented: encapsulation, reusability, etc Many libraries available. Primitives for low level access to hardware/software resources. Can use most existing legacy C code. Most hardware devices provide programming interfaces to C/C++. 4
5 C/C++ build system header file C/C++ is a compiled language: compile + link Object (binary) files can be generated by user compiled files or supplied by libraries. Compilers/linkers exist for the vast majority of platforms. On linux machines: g++ Integrated Development Environments (IDE s) simplify development. E.g. Arduino IDE, Clion, Microsoft Visual Studio, Eclipse, Code blocks, etc 5
6 C/C++ Language Components Core Language + Standard Libraries Core Language Components: Built in types (e.g. int, char, float), operators (e.g. +, &&, >>) and control structures (e.g. for, while, if) Mechanisms for defining new functions, new types, new operators. Libraries: I/O operations (console, files) Strings Containers (e.g. vector, map) Algorithms (search, sort) Threads and Synchronization Time and Random numbers Etc 6
7 C++ Types C++ is a strongly typed language: - Every variable has a type that specifies what can be done with it. - New standards constantly improve type safe programming. C++ is a statically typed language: - The compiler must know the type of each variable Fundamental Types: bool // Boolean, possible values are true and false char // character, for example, 'a', ' z', and '9 int // integer, for example, 1, 42, and 1066 double // double-precision floating-point number, for example, 3.14 and Size of types depends on computer architecture: - use sizeof operator to obtain the right size: e.g. sizeof(int) 7
8 C++ Initialization of Variables C initialization double d1 = 2.3; The first two forms are equivalent. C++ initialization double d2 = 2.3; double d2 (2.3); double d2 2.3; The latter is preferred because it prevents implicit type conversion: int i1 = 7.2; // i1 becomes 7 int i2 7.2; int i3 = 7.2; // error: floating-point to integer conversion (narrowing) // error: floating-point to integer conversion (the = is redundant) 8
9 C++ Automatic Initialization New feature on C++ 11 If the type of the variable can be deduced automatically by the compiler, you can use keywork auto auto b = true; auto ch = 'x'; auto i = 123; auto d = 1.2; auto z = sqrt(y); // a bool // a char // an int // a double // z has the type of whatever sqrt(y) returns 9
10 C++ Operators This is identical to C Arithmetic Operators x + y // plus +x // unary plus x y // minus x // unary minus x * y // multiply x / y // divide x % y // remainder (modulus) Arithmetic Operators (inplace) x += y // x=x+y ++x // increment: x = x+1 x = y // x=x-y x // decrement: x = x-1 x *= y // scaling: x = x*y x /= y // scaling: x = x/y x %= y // x=x%y Relational Operators x == y // equal x!= y // not equal x < y // less than x > y // greater than x <= y // less than or equal x >= y // greater than or equal Logical Operators x && y // logical and x y // logical or x & y // bitwise and x y // bitwise or x ^ y // bitwise xor x >> a // left shift x << a // right shift 10
11 C++ Hello World FILE hello.cpp //the Hello World in c++ #include <iostream> // in C would be #include<stdio.h> int main() std::cout << Hello World << std::endl; //in C would be printf( Hello World\n ); On linux: - Compile with: g++ hello.cpp o hello - Run with:./hello // - line comment <iostream> - Standard library for I/O cout - object for console output, of type ostream defined in the standard library. std:: - specifies that object cout is to be found in the standard library << - operator of the type ostream that writes the right argument into the left argument. std::endl is the new line command; 11
12 Object Oriented Programming One of the the main features of C++. Objects are encapsulations of properties (variables, data) and related behavior (methods, functions) Modularity and scope. Objects are accessible from the outside through a well defined interface. Flexibility and reusability. Object Object member data Object member functions Interface 12
13 Classes Specify properties and behaviors of objects. Expanded concept of data structure: Data + Functions class class_name //declaration access_specifier_1: member1; access_specifier_2: member2;... object_names; object_names are optional names for objects to be created immediately after the class declaration. Access specifiers can be private, public or protected. private members of a class are accessible only from within other members of the same class or from their friends. protected members are accessible from members of their same class and from their friends, but also from members of their derived classes. public members are accessible from anywhere where the object is visible. 13
14 Hello World with Objects FILE hello1.h Class Definition FILE hello1.cpp Class Use FILE main_hello1.cpp #ifndef HELLO1_H #define HELLO1_H //class declaration class Hello1 private: int id; //data public: void run(); //function void set_id(int); ; #endif //HELLO1_H #include hello1.h #include <iostream> using namespace std; //class implementation void Hello1::set_id(int v) if(v>0) //check valid args id = v; else id = 1; void Hello1::run() cout<< Hello <<id<<endl; #include hello1.h #include <stdio.h> //getchar int main() // declare a local object Hello1 obj; // invoke object methods obj.set_id(1); obj.run(); // pause getchar(); // obj is destroyed here. Compile with: g++ -I. hello1.cpp main_hello1.cpp o hello1 14
15 Comments Directives #ifndef, #define, #endif prevent multiple declarations of the contents of the header file. The member access operator (.) is the same as in C structs. Scope operator (::) selects the class of the function to be used - different classes may have the same names for members. Functions run and set_id are public so can be accessed from the outside (in main()). Command using namespace std allows the use of objects from std without the prefix std::. In function declarations, parameter names can be omitted. Member data id is private : cannot be accessed out of the class, i.e. a compiler error is issued if one writes: obj1.id = 4; C++ can use C libraries, e.g. stdio.h Object obj1 is defined in the local memory of main(). When main exits the object is automatically destroyed. Compiler switch -I sets the folder where to find header files. In this case the current folder ( /. ) 15
16 Arduino (AVR) C++ The Arduino files (sketches) have extension.ino and use a subset of the C++ language. //Hello.ino void setup() int counter = 0; int time_delay = 1000; //miliseconds // initialize serial comms to host arduino library Serial.begin(9600); delay function from the Arduino library Serial object from the Arduino library Automatically included void loop() Serial.print( Hello World ); Serial.println(++counter); // print rate to serial monitor delay(time_delay); // wait duration 16
17 A more interesting example const int analoginpin = A0; // Analog input pin that the potentiometer is attached to const int analogoutpin = 9; // Analog output pin that the LED is attached to int sensorvalue = 0; // value read from the pot int outputvalue = 0; // value output to the PWM (analog out) void setup() Serial.begin(9600); // initialize serial communications at 9600 bps void loop() sensorvalue = analogread(analoginpin); // read the analog in value outputvalue = map(sensorvalue, 0, 1023, 0, 255); // map it to the range of the output analogwrite(analogoutpin, outputvalue); // change the analog out value // print the results to the Serial Monitor: Serial.print("sensor = "); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); delay(2); // wait 2 milliseconds before the next loop for the //analog-to-digital converter to settle after the last reading 17
18 Arduino Serial Library if (Serial) available() availableforwrite() begin() end() find() finduntil() flush() parsefloat() parseint() peek() print() println() read() readbytes() readbytesuntil() readstring() readstringuntil() settimeout() write() serialevent() 18
19 Arduino (AVR) Build Process The Arduino IDE uses a specific build process. sketch1.ino.cpp #include <Arduino.h> Arduino Libraries sketch2.ino int main() setup(); for(;;) loop(); avr-g++ +.hex sketchn.ino 19
20 Arduino Other Libraries EEPROM - reading and writing to "permanent" storage. Ethernet / Ethernet 2 - for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH. Firmata - for communicating with applications on the computer using a standard serial protocol. GSM - for connecting to a GSM/GRPS network with the GSM shield. LiquidCrystal - for controlling liquid crystal displays (LCDs). SD - for reading and writing SD cards. Servo - for controlling servo motors. SPI - for communicating with devices using the Serial Peripheral Interface (SPI) Bus. SoftwareSerial - for serial communication on any digital pins. Version 1.0 and later of Arduino incorporate Mikal Hart's NewSoftSerial library as SoftwareSerial. Stepper - for controlling stepper motors. TFT - for drawing text, images, and shapes on the Arduino TFT screen. WiFi - for connecting to the internet using the Arduino WiFi shield. Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors. 20
21 C++ Scopes //LOCAL SCOPE int calc() double y=2; for(int i=0;i++;i<10) //statement scope y *= 2; //local scope for x double x = y; if ( x == 64) break; //end local scope for x y*=2*x; //error: x out of scope y+= i; //OK statement scope for i return i; //error: i is out of scope //FUNCTION PROTOTYPE SCOPE int func1(int i, double x, char* x); //error: conflicting declaration //FUNCTION SCOPE void funct2(int i) // i visible double y; // i and y visible y = i; // i and y visible double x = y; // i, y and x visible //CLASS SCOPE class A // x and i in class scope public: int i; A(double y) x=y;; //y in func. protot. scope protected: double x; 21
22 Scopes Hiding int x; void f() int x; x = 1; x = 3; // global x // local x hides global x // assign to local x int x; // hides first local x x = 2; // assign to second local x // assign to first local x int x; void f2() int x = 1; //local x hides global x ::x = 2; //assign to global x x = 2; //assign to local x //... 22
23 Global Namespace Scope Global scope or global namespace scope is the outermost namespace scope of a program, in which objects, functions, types and templates can be defined. A name has global namespace scope if the identifier's declaration appears outside of all blocks, namespaces, and classes. A name with global scope begins right after its declaration until the end of the translation unit. Definition: Translation unit - A source file and all included headers. A user-defined namespace can be nested within the global scope using namespace definitions 23
24 Namespaces Names of functions, variables, classes are frequently repeated in code from different authors. Example:Two developers, John and Paul, define a function called newtonmethod. How to use both functions in the same program? Namespaces encapsulate code from the same (group of) developer(s) in order to prevent name clashes. //john.h namespace JohnFunctions double newtonmethod(double x0); //paul.h namespace PaulFunctions double newtonmethod(double init); 24
25 Namespaces Now we can use both functions on the same program: If there are no ambiguities, we can use the keyword using to simplify syntax: #include john.h #include paul.h int main() double x = 0, j, p; j = JohnFunctions::newtonmethod(x); p = PaulFunctions::newtonmethod(x); #include john.h using namespace JohnFunctions; int main() double x = 0, j; j = newtonmethod(x); //from John 25
26 Inline functions Function calls have overhead: Copy arguments to the stack Save the return address Save return values For small functions, the overhead can be significant. inline suggests the compiler to copy the function code to where it is called, instead of doing a function call. inline int func(a,b) return (a+1)*b; int main() int x = 3, y = 4, w, z; z = func(x,y); w = func(x,z); int main() int x = 3, y = 4, w, z; z = (x+1)*y; w = (x+1)*z; 26
27 Inline vs Macros Inlines are like macros but behave like functions: Type checking Clear rules for argument passing and return. Check the problem with the following code? How to solve it? #define MYMACRO(x) ((x+1)*(x+2)) int main() int a = 2; MYMACRO(++a); CAVEATS Because the function code is replicated everywhere it is called, this may result in large increases in program size. Inlines should be reserved for small functions. The compiler may decide not to inline a function, if it is too complex. 27
28 Automatic inlines Class member functions are automatic inlines if implemented at declaration time (in-situ). class A public: int id; //automatic inlines A(int i) id = i ; int incr() return id++; Class member function inlines, if not defined in-situ, must be defined in the same file as the class declaration. class A public: int id; A(int); int incr(); //not automatic inlines inline A::A(int i) id = i; inline int A::incr() return id++; 28
Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes
Distributed Real-Time Control Systems Lecture 17 C++ Programming Intro to C++ Objects and Classes 1 Bibliography Classical References Covers C++ 11 2 What is C++? A computer language with object oriented
More informationDistributed Real- Time Control Systems 13/14
Distributed Real- Time Control Systems 13/14 Lecture 10 C++ Programming Operators and more A. Bernardino, C. Silvestre, IST- ACSDC 1 References From C programming we know that int i =3; int *p; p = &i;
More informationInterview Questions of C++
Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.
More informationChapter 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 informationOBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More information6.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 informationTutorial-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 informationCOMP322 - 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 informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationIntroduction 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 informationAN 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 informationC++ 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 informationCE221 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 informationUEE1302 (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 informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationC++ 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 informationCSCE 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 informationVariables and Operators 2/20/01 Lecture #
Variables and Operators 2/20/01 Lecture #6 16.070 Variables, their characteristics and their uses Operators, their characteristics and their uses Fesq, 2/20/01 1 16.070 Variables Variables enable you to
More informationCS 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 informationFast 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 informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationIntroduction 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 informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationCS2141 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 informationArduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.
Introductory Medical Device Prototyping Arduino Part 1, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB Interface
More informationCOMP322 - Introduction to C++
COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments
More informationAppendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.
A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationAbout Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals
More informationLecture 02 C FUNDAMENTALS
Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void
More informationOutline. 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 informationSir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )
Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions.
More informationC++ 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 informationC++ Programming for Non-C Programmers. Supplement
C++ Programming for Non-C Programmers Supplement C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by ITCourseware, 7245 S. Havana St, Suite 100, Centennial, CO 80112
More informationW3101: Programming Languages C++ Ramana Isukapalli
Lecture-6 Operator overloading Namespaces Standard template library vector List Map Set Casting in C++ Operator Overloading Operator overloading On two objects of the same class, can we perform typical
More informationCS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their
More informationEMBEDDED SYSTEMS PROGRAMMING Language Basics
EMBEDDED SYSTEMS PROGRAMMING 2014-15 Language Basics (PROGRAMMING) LANGUAGES "The tower of Babel" by Pieter Bruegel the Elder Kunsthistorisches Museum, Vienna ABOUT THE LANGUAGES C (1972) Designed to replace
More informationWhy C++? C vs. C Design goals of C++ C vs. C++ - 2
Why C++? C vs. C++ - 1 Popular and relevant (used in nearly every application domain): end-user applications (Word, Excel, PowerPoint, Photoshop, Acrobat, Quicken, games) operating systems (Windows 9x,
More informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationEL6483: Brief Overview of C Programming Language
EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions
More informationUNIT- 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 informationCHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object
CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,
More informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationIII. Classes (Chap. 3)
III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More information6.S096 Lecture 4 Style and Structure
6.S096 Lecture 4 Style and Structure Transition from C to C++ Andre Kessler Andre Kessler 6.S096 Lecture 4 Style and Structure 1 / 24 Outline 1 Assignment Recap 2 Headers and multiple files 3 Coding style
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationLooping and Counting. Lecture 3 Hartmut Kaiser hkaiser/fall_2012/csc1254.html
Looping and Counting Lecture 3 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2012/csc1254.html Abstract First we ll discuss types and type safety. Then we will modify the program
More informationCourse Outline Introduction to C-Programming
ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,
More informationLooping and Counting. Lecture 3. Hartmut Kaiser hkaiser/fall_2011/csc1254.html
Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2011/csc1254.html 2 Abstract First we ll discuss types and type safety. Then we will modify the program we developed last time (Framing
More informationBasic 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 informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching
More informationReliable C++ development - session 1: From C to C++ (and some C++ features)
Reliable C++ development - session 1: From C to C++ (and some C++ features) Thibault CHOLEZ - thibault.cholez@loria.fr TELECOM Nancy - Université de Lorraine LORIA - INRIA Nancy Grand-Est From Nicolas
More informationCHAPTER 4 FUNCTIONS. 4.1 Introduction
CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main
More informationProgramming. Elementary Concepts
Programming Elementary Concepts Summary } C Language Basic Concepts } Comments, Preprocessor, Main } Key Definitions } Datatypes } Variables } Constants } Operators } Conditional expressions } Type conversions
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationQUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:
QUIZ 1. Explain the meaning of the angle brackets in the declaration of v below: This is a template, used for generic programming! QUIZ 2. Why is the vector class called a container? 3. Explain how the
More informationFundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University
Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler
More informationCSc Introduction to Computing
CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationDr. Md. Humayun Kabir CSE Department, BUET
C++ Dr. Md. Humayun Kabir CSE Department, BUET History of C++ Invented by Bjarne Stroustrup at Bell Lab in 1979 Initially known as C with Classes Classes and Basic Inheritance The name was changed to C++
More informationCHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++
CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More information1- 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 informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationPIC 10A Objects/Classes
PIC 10A Objects/Classes Ernest Ryu UCLA Mathematics Last edited: November 13, 2017 User-defined types In C++, we can define our own custom types. Object is synonymous to variable, and class is synonymous
More informationFunctions and Recursion
Functions and Recursion 1 Storage Classes Scope Rules Functions with Empty Parameter Lists Inline Functions References and Reference Parameters Default Arguments Unary Scope Resolution Operator Function
More informationLecture 7. Log into Linux New documents posted to course webpage
Lecture 7 Log into Linux New documents posted to course webpage Coding style guideline; part of project grade is following this Homework 4, due on Monday; this is a written assignment Project 1, due next
More informationPROGRAMMING IN C++ KAUSIK DATTA 18-Oct-2017
PROGRAMMING IN C++ KAUSIK DATTA 18-Oct-2017 Objectives Recap C Differences between C and C++ IO Variable Declaration Standard Library Introduction of C++ Feature : Class Programming in C++ 2 Recap C Built
More informationProgramming, numerics and optimization
Programming, numerics and optimization Lecture A-2: Programming basics II Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428 March
More informationChapter 2. Outline. Simple C++ Programs
Chapter 2 Simple C++ Programs Outline Objectives 1. Building C++ Solutions with IDEs: Dev-cpp, Xcode 2. C++ Program Structure 3. Constant and Variables 4. C++ Operators 5. Standard Input and Output 6.
More informationReference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that
Reference Parameters There are two ways to pass arguments to functions: pass-by-value and pass-by-reference. pass-by-value A copy of the argument s value is made and passed to the called function. Changes
More informationA 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 informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationUNIT - I. Introduction to C Programming. BY A. Vijay Bharath
UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been
More informationNumerical Computing in C and C++ Jamie Griffin. Semester A 2017 Lecture 2
Numerical Computing in C and C++ Jamie Griffin Semester A 2017 Lecture 2 Visual Studio in QM PC rooms Microsoft Visual Studio Community 2015. Bancroft Building 1.15a; Queen s W207, EB7; Engineering W128.D.
More informationI Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.
I Internal Examination Sept. 2018 Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. [I]Very short answer questions (Max 40 words). (5 * 2 = 10) 1. What is
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationBy 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 informationObject Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More informationIntroduction 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 informationRecap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam
Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine
More informationLaboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++
Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationVariables. Data Types.
Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting
More informationCSE 303: Concepts and Tools for Software Development
CSE 303: Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 24 Introduction to C++ CSE303 Autumn 2008, Lecture 24 1 C++ C++ is an enormous language: All of C Classes and objects
More informationIntroduction 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 informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationSAURASHTRA UNIVERSITY
SAURASHTRA UNIVERSITY RAJKOT INDIA Accredited Grade A by NAAC (CGPA 3.05) CURRICULAM FOR B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1 Semester - 2) Effective From June
More informationECEN 449 Microprocessor System Design. Review of C Programming
ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh es programming g skills s 2 1 Basic C program structure # include
More informationObjectives. 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 informationRoom 3P16 Telephone: extension ~irjohnson/uqc146s1.html
UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is
More informationChapter 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