16
COP1220/CGS2423 Introduction to C+ +/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Embed Size (px)

Citation preview

Page 1: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

COP1220/CGS2423Introduction to C++/

C for Engineers

Professor: Dr. Miguel Alonso Jr.

Fall 2008

Page 2: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Outline

Why Program? Computer Systems: Hardware and Software Programs and Programming Languages What is a Program Made of? Input, Processing, and Output The Programming Process Procedural and Object-Oriented Programming

Page 3: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Why Program?

What does a computer do? It is useful because it can be programmed, or

told to do many different tasks. They are tools that make almost every

profession easier to do. A computer is a machine specifically

designed to follow instructions.

Page 4: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Why Program?

Programs are called software, or a set of instructions that tells a computer what to do.

Programs in the real world consist of the following: Logical flow of instructions Mathematical procedures Appearance on the screen The way the information is presented to the user The programs “user-friendliness” Manuals and other written documentation

Page 5: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Computer Systems: Hardware and Software

Starting out with C++, Pearson, (2006)

Page 6: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Computer Systems: Hardware and Software

Starting out with C++, Pearson, (2006)

Page 7: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Computer Systems: Hardware and Software

CPU: Controls the computer’s operations and performs arithmetic functions

Main Memory: Random Access Memory, or RAM, is the part of a computer that temporarily holds or stores information

Consists of cells and bits (a “switch” that can be a 0 or 1 Each Cell has 8 bits, or a byte. Each cell is assigned a location number called an

address.

Page 8: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Computer Systems: Hardware and Software

Page 9: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Other Devices

Secondary Storage: Hard Disk, USB Stick Input Devices: Any devices that help the

computer collect information from the outside world

Output Devices: Devices that presents the computer’s information to the outside world.

Page 10: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Software

Generally two categories of software in a computer: Operating system Application Software

Single Tasking Multi-Tasking Single-User Multi-User

Page 11: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Programs and Programming Languages

Computer Program: Set of instructions that tells a computer how to solve a problem or perform a task

Algorithm: A set of well defined steps for performing a task or solving a problem

A computer only understands 0’s and 1’s Programming Languages were invented to

ease the task of programming Examples of Languages: C/C++, C#, JAVA

Page 12: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Programming Languages Low Level vs High Level

Your very first program!

Page 13: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Source Code, Object Code, and Executable

Page 14: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

What is a program made of?

Language Elements

Page 15: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008
Page 16: COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008

Lines, Statements, and Variables

Line: single line as it appears in the body of the program (can be empty)

Statement: complete instruction that causes the computer to perform an action

Variable: named storage location in the computers memory for holding a piece of information. Usually stored in RAM.

Variable definition/declaration Not the same thing!

There are generally two types of variables: numbers and characters. Number: used to compute Characters: used for display