1 / 36

Computer Engineering 1 nd Semester

Computer Engineering 1 nd Semester. Dr. Rabie A. Ramadan http://rabieramadan.org 2. Basics of C++ Environment. Phases of C++ Programs Edit Preprocess Compile Link Load Execute. Program is created in the editor and stored on disk. Preprocessor program processes the code.

molimo
Download Presentation

Computer Engineering 1 nd Semester

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Engineering 1nd Semester Dr. Rabie A. Ramadan http://rabieramadan.org 2

  2. Basics of C++ Environment Phases of C++ Programs Edit Preprocess Compile Link Load Execute Program is created in the editor and stored on disk. Preprocessor program processes the code. Compiler creates object code and stores it on disk. Compiler Linker links the object code with the libraries, creates a.out and stores it on disk Primary Memory Loader Loader puts program in memory. Primary Memory CPU takes each instruction and executes it, possibly storing new data values as the program executes. Preprocessor Linker Editor Disk Disk Disk Disk Disk CPU . . . . . . . . . . . .

  3. Programming environment MSVC (windows) GCC (Linux, Unix) --------------------------------- Many other compilers are available: Ex. Borland c++ Eclips What is IDE integrated development environment : is a software application that provides comprehensive facilities to computer programmers for software development

  4. Using MSVC

  5. Linux & Unix gcc command , and g ++ is the C++ compiler, while cc and CC are the Sun C and C++ It works on both Linux & Unix GCC step by step 1. Write your program on one of the text editors example ( vi or emacs ) 2. Save your file as name.cpp where name is the name of your file 3. Use one of the following ways to compile your program.

  6. Compile then Build g++ -c hello.cpp // compile g++ hello.o -o hello // build

  7. The simple way The standard way to compile this program is with the command g++ hello.cpp -o hello This command compiles hello.cpp into an executable program named "hello" that you run by typing 'hello' at the command line. It does nothing more than print the word "hello" on the screen

  8. Compiling a program with multiplesource files If the source code is in several files, say "file1.cpp" and "file2.", then they can be compiled into an executable program named "myprog" using the following command: g++ file1.C file2.C -o myprog

  9. Compile then Build multiple files g++ -c file1.cpp g++ -c file2.cpp g++ file1.o file2.o -o myprog

  10. Basics of a Typical C++ Environment Input/output cin Standard input stream Normally keyboard cout Standard output stream Normally computer screen cerr Standard error stream Display error messages

  11. Ways to format the program

  12. Ways to format the program

  13. Variables and Data Types A place in Memory To hold an information that a user use. Deceleration SpaceOccupied VariableName;

  14. C++’ Names The name of a variable: Starts with an underscore “_” or a letter, lowercase or uppercase, e.g. _Students, pRice Can include letters, underscore, or digits. Examples are: keyboard, total_grade, _Score_Side1 Cannot include special characters such as !, %, ], or $ Cannot include an empty space Cannot be any of the reserved words Should not be longer than 32 characters (although allowed)

  15. Reserved Words

  16. Variables and Their Data Types The amount of memory space necessary to store a variable is also referred to as a data type.

  17. Variables and Their Data Types char 8 bits short int A group of 16 contiguous bits or 2 bytes, is used to represent a natural number. ranges from –32768 to 32767.

  18. Example

  19. Practice -- what is the o/p

  20. Practice -- what is the o/p

  21. O/P

  22. Representing a Double-Word Double-word combines 4 bytes, or 8 nibbles, or 32 bits. The bits, counted from right to left, start at 0 and end at 31.

  23. What are constants? const PI = 3.14; #define PI 3.14

More Related