Foundations of Computer Science C & C++ programming lecture 2

Slides:



Advertisements
Similar presentations
COSC 120 Computer Programming
Advertisements

Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
Chapter 1 Introduction to Computers and C++ Programming.
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Three types of computer languages
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Introduction to Computers and C++ Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Introduction to Computers and C++ Programming.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Programming With C.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Mohamed Iqbal Pallipurath Slide 1. Mohamed Iqbal Pallipurath Slide 2 Basics Introduction to Computers and C++ Programming.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 October 20, October 20, 2015October 20, 2015October 20,
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
CS CS CS IA: Procedural Programming CS IB: Object-Oriented Programming.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
1 Programming Fundamentals How to Program in C++ How to Program in C++
Copyright © 2012 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
CS Computer Science I. BCPL was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of the.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and C++ Programming.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
Chapter 1: Introduction to Computers and Programming
Computer Basics.
Chapter 1 Introduction to Computers, Programs, and C++
Introduction to Computers and C++ Programming
Introduction to Computers and C++ Programming
Chapter 1: An Overview of Computers and Programming Languages
Computer Terms Review from what language did C++ originate?
Engineering Problem Solving With C An Object Based Approach
CSC201: Computer Programming
Chapter 1 Introduction to Computers, Programs, and C++
Chapter 2 part #1 C++ Program Structure
Instructor: Chien-Ho Ko
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
Hello World 2 What does all that mean?.
Computers: Hardware and Software
2.1 Parts of a C++ Program.
Programming Fundamentals Lecture #3 Overview of Computer Programming
CS IA: Procedural Programming CS IB: Object-Oriented Programming
Introduction to Computer Programming
Programs written in C and C++ can run on many different computers
Computer Terms Review from what language did C++ originate?
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Foundations of Computer Science C & C++ programming lecture 2 CS 2308 Foundations of Computer Science C & C++ programming lecture 2

Outline history of C++ development of C C++ - better C essential computer terms hardware terms software terms C++ program layout, first program

Where did C++ come from? BCPL (Basic Combined Programming Language) was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of UNIX operating system needed a high-level language that provided enough power and flexibility for their task. They developed B (a derivative of BCPL) In 1972, an enhanced and improved version of the language called C was used to code most of UNIX most of operating systems (one of the largest and most complicated pieces of software) is written in C or C++ source code for Microsoft Windows Vista contains 50 million lines of mostly C/C++ code source code Red Hat Linux v.7.1 contains 30 million lines of C/C++ code

The Birth of C++ C++ is an extension of C developed by Bjarne Stroustrup in early 1980s C/C++ are possibly the most popular programming languages in use today C++ absorbed the best features of C and made a few additions to make it even more powerful and convenient to use C was written to combine ease of high-level language with the power of low-level language with C it is very easy to write code that is difficult to understand and hard to debug one of the major additions introduced by C++ is the use of OBJECTS!

Hardware computer contains 5 main components CPU - follows the instructions and performs calculations specified by the program input device - any device that allows outside world to communicate information to the computer output device - any device that allows computer to communicate information to the outside world

Hardware computer contains 5 main components main memory/RAM - a list of addressable numbered memory locations that computer can operate upon bit - the least possible amount of information: 0 or 1 byte - 8 bits memory location - single (indivisible) portion of memory that holds data address - number that identifies a memory location secondary memory - memory that is used for keeping a permanent record of information - disks/data CDs/flash drives

Software operating system - allocates computer resources, launches other programs and makes sure they work properly Program - set of instructions for computer to follow data - input to the program running/executing program - performing program instructions on given data natural language - language used by humans high-level language - language (close to natural) that is understood by humans, C++ is a high-level language low-level language (assembly) - a list of instructions a computer can follow : add X, Y, Z

Software machine language - list of instructions in binary format a computer understands 0001 0001 1001 0001 compiler - a program that translates high-level language into low-level language code - source (high-level language), object (low-level language) library - set of previously developed routines linker - program that takes object code, adds needed routines from libraries and produces executable code executable code - can run on computer

C++ program layout include directive - tells compiler where to find certain items about the program main part (main function) - contain instructions for computer, starts and ends with braces: {} statement - single instruction to computer each statement is ended with semicolon ; program consists of a sequence of statements comment is a portion of line ignored by compiler - serves to make the code easier to understand by humans breaks and indentation is for humans - compiler ignores them. Yet the program should be easy to read! #include <iostream> int main() { statement 1; // comment statement 2; ... }

A First Program - Greeting.cpp // Program: Display greetings // Author(s): Ima Programmer // Date: 1/25/1999 #include <iostream> int main() { cout << "Hello,world!" << endl; } Preprocessor directive Comments Function named main() indicates start of program output statement

Special Characters Character Name Meaning // Double slash Beginning of a comment # Pound sign Beginning of preprocessor directive < > Open/close brackets Enclose filename in #include ( ) Open/close parentheses Used when naming a function { } Open/close brace Encloses a group of statements " " Open/close quotation marks Encloses string of characters ; Semicolon End of a programming statement