Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Foundations of Computer Science C & C++ programming lecture 2"— Presentation transcript:

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

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

3 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

4 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!

5 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

6 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

7 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

8 Software machine language - list of instructions in binary format a computer understands 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

9 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; ... }

10 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

11 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


Download ppt "Foundations of Computer Science C & C++ programming lecture 2"

Similar presentations


Ads by Google