Chapter 1 Introduction to Computers, Programs, and C++

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

Basic Computer Vocabulary
L1:CSC © Dr. Basheer M. Nasef Lecture #1 By Dr. Basheer M. Nasef.
Lecture 1: Overview of Computers & Programming
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 1 Introduction to Computers, Programs,
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 1 Introduction.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
CS102 Introduction to Computer Programming
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 1 Introduction to Computers, Programs, and Python.
Chapter 1 Introduction to Computers, Programs, and Python 1.
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 1 Introduction to Computers, Programs, and C++
Chapter 1 Introduction to Computers, Programs, and Java
Computer Hardware and Software Chapter 1. Overview Brief History of Computers Hardware of a Computer Binary and Hexadecimal Numbers Compiling vs. Interpreting.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computer Science.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Computer and Operating System.
An Abacus. Babbage’s Analytical Engine  Punched cards  First used in Jacquard Loom (1801) to store patterns for weaving cloth  Stored programs in Babbage’s.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Lesson 2 — How Does A Computer Process Data?
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Computer Parts. Two Basic Parts Hardware & Software.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 1 Introduction.
ECOM 2314 Computer Programming I
Chapter 1 Introduction to Computers, Programs, and Java 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved What is a Computer? A computer.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Liang, Introduction to C++ Programming, (c) Chapter 1 Introduction to Computers, Programs, and C++
Chapter 1 Introduction to Computers, Programs, and Java
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 1: Introduction.
The Computer System CS 103: Computers and Application Software.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Chapter 1 Background Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND PYTHON 1.
Chapter 1 Introduction to Computers, Programs, and Python
BASIC PROGRAMMING C SCP1103 (02)
Introduction to Information Structures (MSCIS100)
Computer Science II Chapter 1.
An Overview of the Computer System
Chapter 1: An Overview of Computers and Programming Languages
Objectives To review computer basics, programs, and operating systems (§ ). (Optional) To represent numbers in binary, decimal, and hexadecimal (§1.5.
Chapter 1 Introduction to Computers, Programs, and Java
Topics Introduction Hardware and Software How Computers Store Data
Computer Fundamentals 1
Chapter 1 Introduction to Computers, Programs, and C++
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
Computer Hardware and Software
Principles of Information Technology
Basic Computer Hardware & Software
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Basic Computer Hardware and Software.
Looking Inside the machine (Types of hardware, CPU, Memory)
An Overview of the Computer System
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to computers
Chapter 1 Introduction to Computers, Programs, and C++
CS IA: Procedural Programming CS IB: Object-Oriented Programming
Computer and Operating System slides extended from Liang’s Java Programming textbook by Professor Parson for CSC 352.
Introduction to Computers, Programs, and Java
Presentation transcript:

Chapter 1 Introduction to Computers, Programs, and C++ DDC 2133 Programming II

Objectives To get use in the C++ programming environment To review computer basics, programs, and operating systems. To know the history of C++. To write a simple C++ program. To understand the C++ program development cycle. To develop C++ using C++Builder. To develop C++ using Visual C++ DDC 2133 Programming II

C++ programming environment Choose File >New DDC 2133 Programming II

C++ programming environment Choose Files tab > C++ Source File > Click OK DDC 2133 Programming II

C++ programming environment Area to write program source code DDC 2133 Programming II

Steps in building C++ Program 1st Step write program source code DDC 2133 Programming II

Steps in building C++ Program 2nd Step Click the compile button (Ctrl + F7) (create a default project workspace if not active yet) DDC 2133 Programming II

Steps in building C++ Program 3rd Step Click the Build button (F7) DDC 2133 Programming II

Steps in building C++ Program 4th Step Click the Execute Program button (F7) DDC 2133 Programming II

Steps in building C++ Program Result A Program window will be displayed (if no errors found in compiling process) DDC 2133 Programming II

What is a Computer? A computer consists of a CPU, memory, hard disk, floppy disk, monitor, printer, and communication devices. DDC 2133 Programming II

CPU The central processing unit (CPU) is the brain of a computer retrieves instructions from memory and executes them its speed measured in megahertz (MHz) and gigahertz (GHz) (1 megahertz = 1 million pulses per second) DDC 2133 Programming II

Memory Memory used to store data and program instructions for CPU to execute consists of ordered sequence of bytes (1 byte = 8 bits) program and its data must be brought to memory before they can be executed DDC 2133 Programming II

How Data is Stored? Data of various kinds (numbers, characters, and strings, are encoded as a series of bits (zeros and ones). Computers use zeros and ones because digital devices have two stable states, which are referred to as zero and one by convention. The encoding scheme varies. For example, character ‘J’ is represented by 01001010 in one byte. A small number such as three can be stored in a single byte. A larger number uses multiple adjacent bytes for storage. A byte is the minimum storage unit. DDC 2133 Programming II

Storage Devices Memory is volatile--information is lost when the power is off. Programs and data are permanently stored on storage devices. They are moved to memory when the computer actually uses them. There are three main types of storage devices: Disk drives (hard disks and floppy disks), CD drives (CD-R and CD-RW), and Tape drives. DDC 2133 Programming II

Output Devices: Monitor The monitor displays information (text and graphics). The resolution and dot pitch determine the quality of the display. DDC 2133 Programming II

Monitor Resolution and Dot Pitch The resolution specifies the number of pixels per square inch. Pixels (“picture elements”) are tiny dots that form an image on the screen. The higher the resolution, the sharper and clearer the image is. (307,200 pixels). dot pitch The dot pitch is the amount of space between pixels. The smaller the dot pitch, the better the display. DDC 2133 Programming II

Communication Devices A regular modem uses a phone line and can transfer data in a speed up to 56,000 bps (bits per second). A DSL (digital subscriber line) also uses a phone line and can transfer data in a speed 20 times faster than a regular modem. A cable modem uses the TV cable line. A cable modem is as fast as a DSL. Network interface card (NIC) is a device to connect a computer to a local area network (LAN). A typical type of NIC, called 10BaseT, can transfer data at 10 mbps (million bits per second). DDC 2133 Programming II

Programs A computer program is a set of instructions to the computer. You tell a computer what to do through programs. Computers do not understand human languages, so you need to use computer languages to communicate with them. Programs are written using programming languages. DDC 2133 Programming II

Programming Languages Machine Language Assembly Language High-Level Language Machine language is a set of primitive instructions built into every computer. The instructions are in the form of binary code. Such programs are highly difficult to read and modify (for humans). For example, to add two numbers, you might write an instruction in binary like this: 1101101010011010 DDC 2133 Programming II

Programming Languages Machine Language Assembly Language High-Level Language Assembly languages were developed to make programming easy. A program called assembler is used to convert assembly language programs into machine code. For example, to add two numbers, you might write an instruction in assembly code like this: ADDF3 R1, R2, R3 DDC 2133 Programming II

Programming Languages Machine Language Assembly Language High-Level Language The high-level languages are English-like and easy to learn and program. For example, the following is a high-level language statement that computes the area of a circle with radius 5: area = 5 * 5 * 3.1415; DDC 2133 Programming II

Popular High-Level Languages COBOL (COmmon Business Oriented Language) FORTRAN (FORmula TRANslation) BASIC (Beginner All-purpose Symbolic Instructional Code) Pascal (named for Blaise Pascal) Ada (named for Ada Lovelace) C (whose developer designed B first) Visual Basic (Basic-like visual language developed by Microsoft) Delphi (Pascal-like visual language developed by Borland) C++ (an object-oriented language, based on C) DDC 2133 Programming II

Compiling Source Code Source Program Compiler Object Code A program written in a high-level language Compiler Software use to translate the source program into machine language program Object Code Machine code resulting from compilation process Executable Code Resulting from linking object code with other pieces of code to make the program ready for execution DDC 2133 Programming II

Operating Systems The operating system (OS) is a program that manages and controls a computer’s activities. E.g., Windows 98, NT, 2000, XP, or Vista; Mac; Linux, Unix. Application programs such as an Internet browser and a word processor cannot run without an operating system. DDC 2133 Programming II

Number Systems NOTE: You can skip this section and use it as reference when you have questions regarding binary and hexadecimal numbers. binary 0, 1 0, 1, 2, 3, 4, 5, 6, 7 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F octal decimal hexdecimal DDC 2133 Programming II

Number Systems Computers use binary numbers internally because storage devices like memory and disk are made to store 0s and 1s. A number or a text inside a computer is stored as a sequence of 0s and 1s. Each 0 and 1 is called a bit, short for binary digit. The binary number system has two digits, 0 and 1. Binary numbers are not intuitive, since we use decimal numbers in our daily life. When you write a number like 20 in a program, it is assumed to be a decimal number. Internally, computer software is used to convert decimal numbers into binary numbers, and vice versa. DDC 2133 Programming II

History of C++ C, C++, Java, and C# are very similar. C++ evolved from C. Java was modeled after C++. C# is a subset of C++ with some features similar to Java. C evolved from the B language and the B language evolved from the BCPL language. C++ is an extension of C, developed by Bjarne Stroustrup at Bell Labs during 1983-1985. C++ added a number of features that improved the C language (most importantly, OOP features). DDC 2133 Programming II

A Simple C++ Program Let us begin with a simple C++ program that displays the message “Welcome to C++!” on the console. #include <iostream> int main() { // Display Welcome to C++ to the console std::cout << "Welcome to C++!" << std::endl; return 0; } DDC 2133 Programming II

Extending the Simple C++ Program Once you understand the program, it is easy to extend it to display more messages. For example, you can rewrite the previous program to display three messages. #include <iostream> int main() { std::cout << "Welcome to C++!" << std::endl; std::cout << "Welcome to C++Builder!" << std::endl; std::cout << "Welcome to C++ Compiler!" << std::endl; return 0; } DDC 2133 Programming II

Exercise Write the source code of the following program output: DDC 2133 Programming II

Creating, Compiling, and Running Programs DDC 2133 Programming II