C++ Chap 5
C++ Chap 5
Institute of Technology
Department of Electrical and Computer Engineering
By: Endalkachew D.
Chapter five
Fundamentals of C++ Programming Language
Mechanics of Creating a Program (C++)
C++ programs typically go through five-phase edits, preprocess, compile, linking,
load:
Editor(edit): accepts the typing of the source code (or header file).
Source file: the file that contains the program you prepared in the editor after you
save it.(.cpp)
Header file: header files such as iostream
The preprocessor: is a program that scans the source code for preprocessor
directives such as include directives.
Compiler(compile): translates the source code to machine language.
The compiler is another program that translates the preprocessed source code into
corresponding machine language instructions, which are stored in a separate file,
called an object file, having a .obj extension.
Phase of C++ program
IDE Tools
You can use any plain-text editor such as Notepad to write the source code. You also
can download a free compiler, which usually includes a preprocessor and linker.
There are several IDE tools to write a C++ program such as Code Blocks, Code
Warrior, Dev C++, Quency … etc.
The Structure of C++ Programs
Hello world program:
// my first program in C++
#include <iostream>
using namespace std;
int main ()// main () is where program execution begins.
{
cout << "Hello World!";
return 0;
}
Output:
Hello World!
Cont.…
Sentences that begin with a pound sign (#) are directives for the preprocessor.
They are not executable code lines but indications for the compiler.
#include<iostream> tells the compiler's preprocessor to include the iostream
standard header file. Such as input and output standard files.
Cont.…
07/23/2021 14