Introduction to C/C++
|
|
- Brittney Austin
- 5 years ago
- Views:
Transcription
1 Introduction to C/C++ Joseph Spring School of Computer Science Operating Systems and Computer Networks Lecture Introduction to C/C++ 1
2 Areas for Discussioni Introduction Background Books C++ after Java Linux, xterm and emacs Process Lecture 1 Introduction to C/C++ 2
3 Areas for Discussion Basic Components and Layout Simplest program cout << and cin << Layout Preprocessor Instructions and functions Program and Function Structure Data types Declarations Assignments Statements t t Further Preprocessor Instructions, if... else and count Characters Lecture 1 Introduction to C/C++ 3
4 Introduction Lecture 1 Introduction to C/C++ 4
5 Introduction - Background Last week we looked at using Linux and emacs to create C++ programs. We were interested at that t stage to be able to achieve the following: Getting into Linux, opening the xterm window to execute our programs in Opening up the text editor emacs to enter our source code Lecture 1 Introduction to C/C++ 5
6 Introduction - Background This means we should now be in a position o to: Create directories Move from one directory to another List the contents of a directory Open files for editing Copy and rename files Compile, link and run our programs using statements of the form: g++ datarate1.cpp./a.out Lecture 1 Introduction to C/C++ 6
7 Introduction - Background From an editing perspective we should now be in a position to: Move left and right by one character Move up and down by one line Move to the beginning or end of a file Move to the beginning gor end of a line Insert or delete lines and or characters Move lines or characters Save files with the same or different names Lecture 1 Introduction to C/C++ 7
8 Introduction - Process Programs written in a medium level language ge such as C++ have to be transformed into machine language so that the computer can process the instructions. C++ compilers use a two stage process to achieve this: The compiler translates the program into machine language instructions. i These are stored to memory as an object file The second stage, referred to as linking combines the object file with other object files to produce an executable file With g++ both of these stages are achieved as a single step Once the file is in executable form it can be run and checked to see if it performs as intended Lecture 1 Introduction to C/C++ 8
9 Basic Components and Layout Lecture 1 Introduction to C/C++ 9
10 Basic Components and Layout Example 1 The Simplest Possible Program #include<iostream> using namespace std; main( ) { 1. The program begin with preprocessor instructons. These take the form #include<iostream> using namespace std; Lecture 1 Introduction to C/C++ 10
11 Preprocessor Instructions Preprocessor instructions are: Grouped together at beginning of program Begin with a # character Control the use of libraries of predefined functions and include definitions of symbols used within the program Example 1. #include<iostream> iost eam this file econtains declarations about the standard Input and Output library Lecture 1 Introduction to C/C++ 11
12 Basic Components and Layout #include<iostream> causes the file iostream to be included in the source file before being compiled by the compiler It is used as a convenient way for including lots of standard d declarations and definitions iti iostream contains declarations about the standard input/output library such as: cout, cin,... Lecture 1 Introduction to C/C++ 12
13 Preprocessor Instructions 2. using namespace std; the elements of the standard C++ library are declared within the namespace with the name std. to access its functionality we declare with this expression that we will be using these entities. The line using namespace std; is frequently employed in C++ programs using the standard library Lecture 1 Introduction to C/C++ 13
14 Basic Components and Layout main( ) { 1. The main declaration is an unusual function 1. It is called by operating system not from C++ 2. It can return an int value to the operating system such that 1. 0 denotes normal termination 2. Other values denote abnormal termination 2. Arguments may be included or ignored as required Lecture 1 Introduction to C/C++ 14
15 Basic Components and Layout Example 1 The Simplest Possible Program #include<iostream> using namespace std; main( ) { 1. All C/C++ programs must have reference to the function main 2. When C/C++ programs run they look for and adhere to the definition of main Lecture 1 Introduction to C/C++ 15
16 Basic Components and Layout Example 2 The Next Simplest Possible Program #include<iostream> using namespace std; int main( ) { cout << Hello World << \n ; Lecture 1 Introduction to C/C++ 16
17 Basic Components and Layout int main( ) { cout << Hello World << \n ; 1. The cout << call is used to print whatever follows to the terminal screen 2. The above cout << call prints Hello World folllowed by a new line 3. \n newline, \t is a tab, \b backspace, \\ a backslash Lecture 1 Introduction to C/C++ 17
18 Program and Function Structure Lecture 1 Introduction to C/C++ 18
19 Program and Function Structure 1 /* comments these can occur throughout */ Preprocessor Instructions /* main program */ main( ) { statement 1; statement 2;... statement n; /* function definitions */ function1( () {... functionm( ) {... Lecture 1 Introduction to C/C++ 19
20 Program and Function Structure 1 General form: /* comments these can occur throughout */ Preprocessor Instructions /* main program */ main( () { statement 1; statement 2;... statement n; Lecture 1 Introduction to C/C++ 20
21 Program and Function Structure 1 main() {... /* function definitions */ function1( ) { statement 1;... statement n; functionm( () {... Lecture 1 Introduction to C/C++ 21
22 Program and Function Structure 1 /* comments these can occur throughout */ Preprocessor Instructions /* main program */ main( ) { statement 1; statement 2;... statement n; /* function definitions */ function1( () {... functionm( ) {... Lecture 1 Introduction to C/C++ 22
23 Program Structure 1. Comments which can occur throughout 2. Preprocessor instructions 3. The main program 4. Function definitions A C/C++ program must contain: 1. The function main( ) 2. Program statements contained between the curly brackets { and Lecture 1 Introduction to C/C++ 23
24 Data Types, Declarations, Assignments and Statements Lecture 1 Introduction to C/C++ 24
25 Programs pot.cpp #include<iostream.h> using namespace std; int main( ) { int pot = 1; while(pot < 10000) { cout << pot << \n ; pot = pot * 2; Lecture 1 Introduction to C/C++ 25
26 Data Types The integer family int machine dependent, but normally 32 bits long 32 bit short 16 bit char 8 bit (Note, char is a very short int) The unsigned family these are obtained by preceding the int family with unsigned They denote positive values Lecture 1 Introduction to C/C++ 26
27 Data Types The floating point type double is usually 64 bits float is usually 32 bit The boolean or logical type bool yields true or false Example while(pot < 10000) The expression pot < is either true or fl false; boolean. Lecture 1 Introduction to C/C++ 27
28 Declarations Declarations involve a type (such as int) followed by variable(s) Example 1: int pot = 1; Example 2: double rate=0.0, time=0.0, mb=0.0; Note the use of commas in the second example Lecture 1 Introduction to C/C++ 28
29 Statements The while statement is one that you will have met in the tutorial. It s form is: while (expression) statement Theexpression is evaluated if true then the statement t t that t follows is executed If false then the while statement stops and statements following the while statement are executed In the Powers of Two program pot.cpp the expression is pot < Lecture 1 Introduction to C/C++ 29
30 Assignments C++ just uses = for the assignment operator In the pot.cpp program we meet: pot = pot * 2 In this line two times the pot variable is assigned to the pot variable In the datarate1.cpp program the mb variable is assigned the product of the rate and time variables Note the use of the assignment operator in fibon.cpp Lecture 1 Introduction to C/C++ 30
31 Programs datarate1.cpp #include<iostream.h> using namespace std; int main( ) { double rate =0.0, time=0.0, mb=0.0; while(true) { cout << input rate in Mb/sec: ; cin >> rate; cout << input time in seconds (1 milli=0.001): ; cin >> time; mb = rate * time; cout << data transferred = << mb << Mb\n ; cout << data transferred = << mb/8 << MB\n ; Lecture 1 Introduction to C/C++ 31
32 Programs datarate2.cpp #include<iostream.h> using namespace std; int main( ) { double rate =0.0, 0 time=0.0, 0 mb=0.0; 0; while(true) { cout << input rate in Mb/sec: ; cin >> rate; cout << input amount of data in MB (megabytes): ; cin >> mb; time = (mb*8) / rate; cout << time for transfer = << time << secs\n ; Lecture 1 Introduction to C/C++ 32
33 Programs fibon.cpp #include<iostream.h> using namespace std; int main( ) { int last, last_ but_ one, new_ last; last_but_one = 0; last = 1; while(last< 10000) { cout << last << ; new_last =last+last last_but_one; last_but_one = last; last = new_last; cout << \n ; Lecture 1 Introduction to C/C++ 33
34 Further Preprocessor Instructions, The if... else... Conditional Statement, and count Lecture 1 Introduction to C/C++ 34
35 Programs largest.cpp #include <iostream> #include <limits.h> using namespace std; int main( (){ int num, count=0, max_so_far=int_min; while ( cin >> num ) { if ( num > max_so_far ) max_so_far = num; count = count + 1; if ( count > 0 ) cout << "largest = " << max_so_far _ << "\n"; else cout << "no numbers input\n"; Lecture 1 Introduction to C/C++ 35
36 Further Preprocessor Instructions The program largest.cpp introduces a new preprocessor instruction: #include <limits.h> limits.h contains definitions of a range of integer constants, for example, the largest and smallest int, unsigned int, float, double,... The program largest.cpp uses the symbolic constant INT_MIN the smallest int value defined in limits.h The definitions are dependent upon the implementation employed limits.hit is from Chence the use of.h in the name Lecture 1 Introduction to C/C++ 36
37 The if... else... Conditional Statement The program largest.cpp introduces the following conditional statement: if ( count > 0 ) cout << "largest = " << max_so_far << "\n"; else cout << "no numbers input\n"; The general form for conditional statements is: if (expression) statement 1 else statement 2 Here the expression is evaluated. If it is true the statement 1 is executed. If it is false then statement 2 is executed Lecture 1 Introduction to C/C++ 37
38 The count variable The program largest.cpp also introduces the count variable count=0;... count = count t+ 1; if ( count > 0 ) cout << "largest = " << max_so_far << "\n"; " else cout << "no numbers input\n ; The count variable is useful in the above context and also when printing the first n values in a sequence For example, the first 18 Fibonacci numbers Lecture 1 Introduction to C/C++ 38
39 Characters Lecture 1 Introduction to C/C++ 39
40 Programs copy1.cppcpp #include <iostream> using namespace std; int main() { char c; while ( cin.get(c) ) cout.put(c); Lecture 1 Introduction to C/C++ 40
41 copy1.cppcpp This program copies the standard input to the standard output The statement cin.get(c) reads in characters from standard input into the variable c The statement t t while ( cin.get(c) ())) cout.put(c); (); returns the value true if a character is stored in the variable c and executes cout.put(c) writing the character to the standard output Lecture 1 Introduction to C/C++ 41
42 copy2.cppcpp This program also copies the standard input to the standard output, however it omits spaces, newlines and tabs for example Output from the program copy2.cpp is given on the Running copy2.cpp cpp slide Lecture 1 Introduction to C/C++ 42
43 Programs copy2.cppcpp #include <iostream> using namespace std; int main() { char c; while ( cin >> c ) cout << c; Lecture 1 Introduction to C/C++ 43
44 Running copy2.cppcpp rabbit(273)$ g++ copy2.cpp pp rabbit(274)$./a.out < copy2.cpp #include<iostream>intmain(){charc;while(cin>>c)cout<<c; Lecture 1 Introduction to C/C++ 44
45 Programs wrap.cpp #include <iostream> const int LINELENGTH = 30; using namespace std; int main() { int pos = 0; char c; while ( cin.get(c) ) { if (c == \n ) pos = 0; else pos = pos + 1; if (pos > LINELENGTH) { cout << \n ; pos = 1; cout << c; Lecture 1 Introduction to C/C++ 45
46 wrap.cpp wrapping text and equality The program wrap.cpp ensures reads standard input and prints the text tto the standard doutput t(terminal) ensuring that each line of output is no longer than 30 characters If the linelength is greater than 30 then the newline character \n is inserted and the text continues on the next line Note the test for equality cin == \n uses the double equal sign. Recall a single equals sign is used for assignment or within an equation. The corresponding sign for not equal to would be!= Lecture 1 Introduction to C/C++ 46
47 wrap.cpp character constants Character constants are given in... Examples \n linefeed \b backspace \o null \t tab \r carriage return Lecture 1 Introduction to C/C++ 47
48 Summary Introduction Background Books C++ after Java Linux, xterm and emacs Process Basic Components and Layout Simplest program cout << and cin << Layout Preprocessor Instructions and functions Program and Function Structure Data types Declarations Assignments Statements Further Preprocessor Instructions, if... else and count Characters Lecture 1 Introduction to C/C++ 48
C++ Functions. Last Week. Areas for Discussion. Program Structure. Last Week Introduction to Functions Program Structure and Functions
Areas for Discussion C++ Functions Joseph Spring School of Computer Science Operating Systems and Computer Networks Lecture Functions 1 Last Week Introduction to Functions Program Structure and Functions
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
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 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 informationChapter 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 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 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 informationIntroduction 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 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 informationObjectives. 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 information2 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 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 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 information2.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 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 informationC++ 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 informationComputer 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 informationEC 413 Computer Organization
EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages
More informationIntroduction 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 informationSummary 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! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc.
Week 1: Introduction to C++ Gaddis: Chapter 2 (excluding 2.1, 2.11, 2.14) CS 1428 Fall 2014 Jill Seaman Literals A literal represents a constant value used in a program statement. Numbers: 0, 34, 3.14159,
More informationCHAPTER 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 informationGetting started with C++ (Part 2)
Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output
More informationStructured Programming Using C++ Lecture 2 : Introduction to the C++ Language. Dr. Amal Khalifa. Lecture Contents:
Structured Programming Using C++ Lecture 2 : Introduction to the C++ Language Dr. Amal Khalifa Lecture Contents: Introduction to C++ Origins Object-Oriented Programming, Terms Libraries and Namespaces
More informationThe sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.
CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing
More informationC++ 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 informationYour first C++ program
Your first C++ program #include using namespace std; int main () cout
More informationInput And Output of C++
Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout
More informationTHE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)
THE INTEGER DATA TYPES STORAGE OF INTEGER TYPES IN MEMORY All data types are stored in binary in memory. The type that you give a value indicates to the machine what encoding to use to store the data in
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
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 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 informationC++ 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 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 informationLECTURE 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 informationInteger Data Types. Data Type. Data Types. int, short int, long int
Data Types Variables are classified according to their data type. The data type determines the kind of information that may be stored in the variable. A data type is a set of values. Generally two main
More informationC++ Programming Basics
C++ Programming Basics Chapter 2 and pp. 634-640 Copyright 1998-2011 Delroy A. Brinkerhoff. All Rights Reserved. CS 1410 Chapter 2 Slide 1 of 25 Program Components Function main P Every C/C++ program has
More informationCS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++
CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ 10 Stacks of Coins You have 10 stacks with 10 coins each that look and feel
More informationLab # 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 informationUnderstanding 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 informationChapter 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 informationChapter 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 informationCSCI 1061U Programming Workshop 2. C++ Basics
CSCI 1061U Programming Workshop 2 C++ Basics 1 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output
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 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 informationC++ 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 informationOverview. - 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 informationSuperior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1
Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.1 Introduction of Compiler, Comments, Program Structure, Input Output, Data Types and Arithmetic Operators
More information1.1 Introduction to C Language. Department of CSE
1.1 Introduction to C Language 1 Department of CSE Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to
More informationYour First C++ Program. September 1, 2010
Your First C++ Program September 1, 2010 Your First C++ Program //*********************************************************** // File name: hello.cpp // Author: Bob Smith // Date: 09/01/2010 // Purpose:
More informationMultiple 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 informationIDE: Integrated Development Environment
Name: Student ID: Lab Instructor: Borja Sotomayor Do not write in this area 1 2 3 TOTAL Maximum possible points: 30 One of the goals of this lab is to introduce the Eclipse IDE, a software environment
More informationCSI33 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 informationProgramming with C++ as a Second Language
Programming with C++ as a Second Language Week 2 Overview of C++ CSE/ICS 45C Patricia Lee, PhD Chapter 1 C++ Basics Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Introduction to
More informationChapter 1. C++ Basics. Copyright 2010 Pearson Addison-Wesley. All rights reserved
Chapter 1 C++ Basics Copyright 2010 Pearson Addison-Wesley. All rights reserved Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment
More informationFrom Pseudcode Algorithms directly to C++ programs
From Pseudcode Algorithms directly to C++ programs (Chapter 7) Part 1: Mapping Pseudo-code style to C++ style input, output, simple computation, lists, while loops, if statements a bit of grammar Part
More informationThis watermark does not appear in the registered version - Slide 1
Slide 1 Chapter 1 C++ Basics Slide 2 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output Program Style
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 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 informationChapter 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 information1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?
1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity
More informationChapter 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 informationChapter 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 informationChapter 7: User-Defined Simple Data Types, Namespaces, and the string Type
Strings Chapter 7: User-Defined Simple Data Types, Namespaces, and the string Type A string is a sequence of characters. Strings in C++ are enclosed in "". Examples: "porkpie" "TVC15" (a 7-character string)
More information1. In C++, reserved words are the same as predefined identifiers. a. True
C++ Programming From Problem Analysis to Program Design 8th Edition Malik TEST BANK Full clear download (no formatting errors) at: https://testbankreal.com/download/c-programming-problem-analysis-program-design-8thedition-malik-test-bank/
More informationMA400: 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 informationME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types
ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants
More informationToday. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed
CS 150 Introduction to Computer Science I Data Types Today Last we covered o main function o cout object o How data that is used by a program can be declared and stored Today we will o Investigate the
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationCS31 Discussion 1E. Jie(Jay) Wang Week3 Oct.12
CS31 Discussion 1E Jie(Jay) Wang Week3 Oct.12 Outline Problems from Project 1 Review of lecture String, char, stream If-else statements Switch statements loops Programming challenge Problems from Project
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 informationComputer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:
Computer Department Program: Computer Midterm Exam Date : 19/11/2016 Major: Information & communication technology 1 st Semester Time : 1 hr (10:00 11:00) Course: Introduction to Programming 2016/2017
More informationGE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004
GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout
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 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 informationCHAPTER 3 BASIC INSTRUCTION OF C++
CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers
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 informationIntroduction 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 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 informationIntroduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2
Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Administrative This class is currently FULL and
More informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic
More informationComputer Science II Lecture 1 Introduction and Background
Computer Science II Lecture 1 Introduction and Background Discussion of Syllabus Instructor, TAs, office hours Course web site, http://www.cs.rpi.edu/courses/fall04/cs2, will be up soon Course emphasis,
More informationADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1
NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.
More informationBTE2313. Chapter 2: Introduction to C++ Programming
For updated version, please click on http://ocw.ump.edu.my BTE2313 Chapter 2: Introduction to C++ Programming by Sulastri Abdul Manap Faculty of Engineering Technology sulastri@ump.edu.my Objectives In
More information! 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 informationLecture 3. More About C
Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants
More informationTypescript on LLVM Language Reference Manual
Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making
More informationProfessor Peter Cheung EEE, Imperial College
1/1 1/2 Professor Peter Cheung EEE, Imperial College In this lecture, we take an overview of the course, and briefly review the programming language. The rough guide is not very complete. You should use
More informationWelcome 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 informationCS242 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 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 informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationChapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will:
Chapter 8 Arrays and Strings Objectives In this chapter, you will: Learn about arrays Declare and manipulate data into arrays Learn about array index out of bounds Learn about the restrictions on array
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 informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationChapter 2. C++ Syntax and Semantics, and the Program Development Process. Dale/Weems 1
Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems 1 Chapter 2 Topics Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables
More informationMultiple 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 informationProgramming 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 informationo Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement
Last Time Let s all Repeat Together 10/3/05 CS150 Introduction to Computer Science 1 1 We covered o Counter and sentinel controlled loops o Formatting output Today we will o Type casting o Top-down, stepwise
More information