Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 13011 CS 13012 CS IA: Procedural Programming CS IB: Object-Oriented Programming.

Similar presentations


Presentation on theme: "CS 13011 CS 13012 CS IA: Procedural Programming CS IB: Object-Oriented Programming."— Presentation transcript:

1 CS 13011 CS 13012 CS IA: Procedural Programming CS IB: Object-Oriented Programming

2 l BCPL was developed in 1967 as a language for writing operating systems and software compilers l 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) l In 1972, an enhanced and improved version of the language called C was used to code most of UNIX l most of operating systems (one of the largest and most complicated pieces of software) is written in C or C++ n source code for Microsoft Windows Vista contains 50 million lines of mostly C/C++ code n source code Red Hat Linux v.7.1 contains 30 million lines of C/C++ code Where did C++ come from? 2

3 l C++ is an extension of C developed by Bjarne Stroustrup in early 1980s l C/C++ are possibly the most popular programming languages in use today l C++ absorbed the best features of C and made a few additions to make it even more powerful and convenient to use n 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 n one of the major additions introduced by C++ is the use of OBJECTS! The Birth of C++ 3

4 l program - set of instructions to computer l software - collection of programs l hardware - physical devices that make up computer equipment l computer - PC/mainframes/workstations l computer contains 5 main components n CPU - follows the instructions and performs calculations specified by the program n input device - any device that allows outside world to communicate information to the computer n output device - any device that allows computer to communicate information to the outside world n 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 n secondary memory - memory that is used for keeping a permanent record of information - disks/data CDs/flash drives Hardware 4

5 Hardware Diagrams 5

6 l operating system - allocates computer resources, launches other programs and makes sure they work properly l program (again) - set of instructions for computer to follow l data - input to the program l running/executing program - performing program instructions on given data l natural language - language used by humans l 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 l machine language - list of instructions in binary format a computer understands 0101 0001 1100 0010 l compiler - a program that translates high-level language into low-level language l code - source (high-level language), object (low-level language) l library - set of previously developed routines l linker - program that takes object code, adds needed routines from libraries and produces executable code l executable code - can run on computer Software 6

7 Software Cycle Diagam add include files executable code source code (add1.cpp) check file unit for legal syntax and compile it into an object code link object code with pre-compiled routines from standard libraries to produce executable code include files (add1.h, iostream) done by compiler object code (add1.o) standard libraries done by linker 7

8 l 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: {} l statement – single unit of execution each statement is ended with semicolon ; l program consists of a sequence of statements l comment is a portion of line ignored by compiler - serves to make the code easier to understand by humans l breaks and indentation is for humans - compiler ignores them. Yet the program should be easy to read! C++ Program Layout #include int main() { statement 1; // comment statement 2;... } 8

9 // displays a greeting // Mikhail Nesterenko // 8/25/2013 #include using std::cout; using std::endl; int main() { cout << "Hello, World!" << endl; } First Program: helloWorld.cpp preprocessor directive output statement comments function named main() indicates start of program

10 Rules of Programming l syntax - the principles of constructing (structuring) the program l semantics – the meaning of the program and its parts style – non-syntactic rules of program writing aimed at making program easier to read and understand 10


Download ppt "CS 13011 CS 13012 CS IA: Procedural Programming CS IB: Object-Oriented Programming."

Similar presentations


Ads by Google