Three types of computer languages

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

EC-111 Algorithms & Computing Lecture #1 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Lecture 2 Introduction to C Programming
CS 6301 Lecture 2: First Program1. CS Topics of this lecture Introduce first program  Explore inputs and outputs of a program Arithmetic using.
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1 Introduction 1.2 What is a Computer?
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.6 Machine Languages, Assembly Languages,
Introduction Kingdom of Saudi Arabia Shaqra University
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline History of C and C++ C++ Standard Library Object Technology Basics.
 2003 Prentice Hall, Inc. All rights reserved Computer Organization Six logical units of computer 1.Input unit “Receiving” section Obtains information.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
Introduction to C Programming
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Chapter 01: Introduction to Computer Programming
COMPUTER SCIENCE I C++ INTRODUCTION
CSCI 1730 January 17 th, 2012 © by Pearson Education, Inc. All Rights Reserved.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
 2008 Pearson Education, Inc. All rights reserved. 1 The chief merit of language is clearness. — Galen Our life is frittered away by detail…. Simplify,
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
COMPSCI 174- Introduction to C++ Class hour Section 01: MWF 9:55am – 10:45am. Hyer Hall 210.
Spring 2005, Gülcihan Özdemir Dağ BIL104E: Introduction to Scientific and Engineering Computing, Spring Outline 1.1Introduction 1.2What Is a Computer?
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.1 Introduction 1.2 What is a Computer?
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introduction to Computers Outline 1.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
 2008 Pearson Education, Inc. All rights reserved. 1 CISC 1600 – Computer Science I Fall 2010 Introduction to C++ Programming Chapters 1 and 2 (Deitel.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Week 1 Algorithmization and Programming Languages.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
1 Programming Fundamentals How to Program in C++ How to Program in C++
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
Announcements Starting next week class 6-8 on Thursday Homework 1 on the web  Due January 29 – next class meeting  Homework policy No late assignments.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
CHAPTER 1.1 INTRODUCTION TO COMPUTERS AND C++ Dr. Shady Yehia Elmashad.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 Introduction to C++ Programming Outline Introduction Machine Languages, Assembly Languages, and High-Level Languages History of C++ C++ Standard Library.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Introduction to C++ Programming Lecture 1 Aug 31, 2004.
 2003 Prentice Hall, Inc. All rights reserved Introduction Software –Instructions to command computer to perform actions and make decisions Hardware.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1: Introduction to computers and C++ Programming
Introduction to C++ Programming
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
1.2 What is a Computer? Computer Computer programs Hardware Software
Introduction to C++ Programming
1.13 The Key Software Trend: Object Technology
Introduction to C++ Programming
Chapter 1 – Introduction to Computers and C++ Programming
Introduction to Computer Programming
Programs written in C and C++ can run on many different computers
Capitolo 1 – Introduction C++ Programming
Introduction to C Programming
Presentation transcript:

Three types of computer languages Machine language Only language computer directly understands “Natural language” of computer Defined by hardware design Machine-dependent Generally consist of strings of numbers Ultimately 0s and 1s Instruct computers to perform elementary operations - One at a time Cumbersome for humans Example: +1300042774 +1400593419 +1200274027

Three types of computer languages Assembly language English-like abbreviations representing elementary computer operations Clearer to humans Incomprehensible to computers Translator programs (assemblers) Convert to machine language Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

Three types of computer languages High-level languages Similar to everyday English, use common mathematical notations Single statements accomplish substantial tasks Assembly language requires many instructions to accomplish simple tasks Translator programs (compilers) Convert to machine language Interpreter programs Directly execute high-level language programs Example: grossPay = basePay + overTimePay

History of C and C++ Evolved from two other programming languages BCPL and B - “Typeless” languages Dennis Ritchie (Bell Laboratories) Added data typing, other features Development language of UNIX Hardware independent Portable programs 1989: ANSI standard 1990: ANSI and ISO standard published ANSI/ISO 9899: 1990

History of C and C++ History of C++ Extension of C Early 1980s: Bjarne Stroustrup (Bell Laboratories) “Spruces up” C Provides capabilities for object-oriented programming Objects: reusable software components Model items in real world Object-oriented programs Easy to understand, correct and modify Hybrid language C-like style Object-oriented style Both

C++ Standard Library C++ programs C++ standard library Built from pieces called classes and functions C++ standard library Rich collections of existing classes and functions “Building block approach” to creating programs “Software reuse”

Basics of a Typical C++ Environment Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker   CPU . Disk Phases of C++ Programs: Edit Preprocess Compile Link Load Execute

Basics of a Typical C++ Environment Input/output cin Standard input stream Normally keyboard cout Standard output stream Normally computer screen cerr Standard error stream Display error messages

Introduction to C++ Programming C++ language Facilitates structured and disciplined approach to computer program design Following several examples Illustrate many important features of C++ Each analyzed one statement at a time Structured programming Object-oriented programming

A simple program that print a line of text #include<iostream> using namespace std; int main() { cout<< “Welcome\n”; return 0; } // end of function

A Simple Program: Printing a Line of Text Comments Document programs Improve program readability Ignored by compiler Single-line comment Begin with // /* ……… ….. */ Preprocessor directives Processed by preprocessor before compiling Begin with #

Standard output stream object std::cout “Connected” to screen << Stream insertion operator Value to right (right operand) inserted into output stream Namespace std:: specifies using name that belongs to “namespace” std std:: removed through use of using statements Escape characters -\ Indicates “special” character output

Another example – add two integer numbers #include<iostream> using namespace std; int main() { int integer1, integer2; int sum; cout<<“Enter two numbers\n”; cin>> integer1 >> integer2; sum = integer1+ integer2; cout<< “ Sum of two numbers is” <<sum<<endl; return 0; }

Location in memory where value can be stored Variables Location in memory where value can be stored Common data types int - integer numbers char - characters double - floating point numbers Declare variables with name and data type before use int integer1; int integer2; int sum; Can declare several variables of same type in one declaration Comma-separated list int integer1, integer2, sum;

Variables Variable names Valid identifier Series of characters (letters, digits, underscores) Cannot begin with digit Case sensitive

Input stream object >> (stream extraction operator) Used with cin Waits for user to input value, then press Enter (Return) key Stores value in variable to right of operator Converts value to variable data type = (assignment operator) Assigns value to variable Binary operator (two operands) Example: sum = variable1 + variable2;

Memory Concepts Variable names Correspond to actual locations in computer's memory Every variable has name, type, size and value When new value placed into variable, overwrites previous value Reading variables from memory nondestructive

Memory Concepts cin >> integer1; cin >> integer2; 45 cin >> integer1; Assume user entered 45 cin >> integer2; Assume user entered 72 sum = integer1 + integer2; integer1 45 integer2 72 integer1 45 integer2 72 sum 117