0% found this document useful (0 votes)
58 views

Programming in C++

The document discusses strategies for learning C++, including focusing on concepts rather than language features, learning C++ to become a better programmer, and learning it gradually. It provides background on the development of C++, describing how it was created by Bjarne Stroustrup in the 1980s as a superset of C with added object-oriented features. It also outlines the basic anatomy of a C++ program, including text editors, compilers, linkers, and producing an executable program output.

Uploaded by

usman hanif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Programming in C++

The document discusses strategies for learning C++, including focusing on concepts rather than language features, learning C++ to become a better programmer, and learning it gradually. It provides background on the development of C++, describing how it was created by Bjarne Stroustrup in the 1980s as a superset of C with added object-oriented features. It also outlines the basic anatomy of a C++ program, including text editors, compilers, linkers, and producing an executable program output.

Uploaded by

usman hanif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Programming in C++

Strategies for learning C++


• Focus on concepts and programming techniques.
(Don’t get lost in language features)
• Learn C++ to become a better programmer
More effective at designing and implementing.
• Learn C++ gradually
Don’t have to know every detail of C++ to
write a good C++ program.
Introduction
Alexander Graham Bell
• C Language developed by Brian M Kernighan and
Dennis Ritchie at Bell Labs in early 1970’s
• Unix OS developed in C language
• Inherited from two previously programming
languages BCPL and “B”.
• BCPL “Basic Combined Programming
Language”) A programming language developed
by Martin Richards in Cambridge in 1967
• C++ is a superset of C language, 1980
Introduction
C++ was written by  Bjarne
Stroustrup at Bell Labs during 1983-
1985.  Prior to 1983, Bjarne Stroustrup
added features to C and formed what
Bjarne Stroustrup he called "C with Classes". He had
combined the use of classes and
object-oriented features with the power
and efficiency of C. The term C++ was
first used in 1983.
C++ program Execution

Text Editor Compiler Linker

Run Program

Program Output

Source File
Object File
Program
• An ordered list of events to take place or procedures to
be followed; a schedule
• A collection of instructions that tell the computer to do
specific activity.
• A program is generally known as "software“
• Application programs
• System Software
Program
• the terms software, application, program and
instruction are synonymous in the sense that they all
tell the computer to do some specific activity.

• A program is written in a programming language, such


as C or C++

• assemblers, compilers and interpreters.

• The program contains machine instructions, buffers,


constants and counters.
The Anatomy of a Program

A program is made up of machine instructions, buffers,


constants and counters. The program's logic is
embedded within the instructional sequence.
Algorithm
• A step-by-step problem-solving procedure, especially an
established, computational procedure for solving a
problem in a finite number of steps.

• A set of ordered steps for solving a problem, such as a


mathematical formula or the instructions in a program.

• algorithm and logic


Programming Languages
• High Level Language
• Low Level Language/Machine
Language
• Intermediate Level Language
Variable

In computer science and mathematics, a variable


(sometimes called a pronumeral) is a symbol
denoting a quantity or symbolic representation. In
mathematics, a variable often represents an
unknown quantity that has the potential to change;
in computer science, it represents a place where a
quantity can be stored. Variables are often
contrasted with constants, which are known and
unchanging.
Data
03091989 03/09/1989

• 600 Integer Number


• 7.821 Real Number
• “Programming
Strings
Languages-1”

Variables are used for manipulating such type


of data
Variable declaration
Variable declaration
In C: all variable definitions must occur at the beginning of a
block.

int i;
for (i=0; i<5; i++) { ... }

In C++: variable definitions may occur at the point of use.


for(int i=0; i<5; i++) { ... }
Reserved Words
C++ reserved key word that can not be used as an identifier:

• asm, auto, bool, break, case, catch, char, class, const, const_cast,
continue, default, delete, do, double, dynamic_cast, else, enum,
explicit, extern, false, float, for, friend, goto, if, inline, int, long,
mutable, namespace, new, operator, private, protected, public, register,
reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct,
switch, template, this, throw, true, try, typedef, typeid, typename,
union, unsigned, using, virtual, void, volatile, wchar_t.
• and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq.
• far, huge, near (for some compiler).
Boolean
Boolean literals
There are only two valid Boolean values: true and false.
These can be expressed in C++ as values of type bool
by using the Boolean literals true and false.

Example:
bool flag1, flag2;
flag1 = false;
flag2 = true;

false will give 0 value


true will give 1 value
Scope of variables
Fundamental Data Types

You might also like