4-Lec - Introduction To C++ Programming
4-Lec - Introduction To C++ Programming
4-Lec - Introduction To C++ Programming
CSC102
1
What is C/C++?
A language written by Brian Kernighan and
Dennis Ritchie. This was to be the language
that UNIX was written in to become the first
"portable" language
In 1972 Dennis Ritchie at Bell Labs writes C and in
1978 the publication of The C Programming
Language by Kernighan & Ritchie caused a
revolution in the computing world
C++ was developed by Bjarne Stroustrup at Bell Labs
since 1979, as an extension of the C language
In recent years C/C++ has been used as a general-purpose
language because of its popularity with programmers.
2
Why use C/C++?
Mainlybecause it produces code that runs nearly as fast as
code written in assembly language. Some examples of the use
of C might be:
◦ Operating Systems
◦ Language Compilers
◦ Device Drivers
◦ Database
◦ Application Programs
◦ Utilities
3
C++ Compilation Process
4
Development with C++
Six stages
Editing: Writing the source code by using some IDE
or editor
Preprocessing or libraries: Already available
routines
compiling: translates or converts source to object
code for a specific platform source code -> object
code
linking: resolves external references and produces
the executable module
loading: loads program for execution
execution: execution or running of program
5
Example Program: A Program to
find sum of two numbers
Requirements Specification: Develop a program
that does the following:
6
Analysis
7
Program Design
8
Source Code
9
Execution - Output
10
Algorithm
An algorithm is defined as a well-defined
sequence of steps that provides a solution
for a given problem.
Algorithms are generally written in a
natural language or plain English
language
11
Simple C++ Program
12
Simple C++ Program
Line 1: // A first C++ Program
13
Simple C++ Program
Line 2: #include <iostream>
14
Simple C++ Program
Line 3: using namespace std;
15
Simple C++ Program
Line 5: int main()
16
Simple C++ Program
Line 6: {
17
Simple C++ Program
Line 7: cout<<“Welcome to FURC\n";
18
Simple C++ Program
Line 8: }
This closing bracket denotes the end of
the program.
19
Escape Sequence
‘\’is an escape character: causes an escape from the
normal interpretation of string, the next character
recognized as having a special meaning.
\n new line
\t tab
\b backspace
\r carriage return
\’ single quote
\” double quote
\\ backslash
20