1 Introduction
1 Introduction
Muhammad Ali
Course Outline Week-Wise
Week Topic
Introduction:
1 Introduction to the course and main topics.
Course Objectives
Overview of Computers and Programming:
2 Computers and data processing, Overview of the computer system and
programming
Other Operators:
4 Relational Operators, Logical Operators, Assignment, Conditional Expression
Operator, Precedence of Operators
5
Week Topic
14
Control Flow:
Nesting if, switch, More about switch and multiple selection
15
Loops Concept:
Looping, for loop, for loop examples, Stepping with for,
Loops:
16 while loop, Semicolon Warning! , while vs do while and for loop, Extending
the for loop, break, continue
17 Final EXAM
Reference Books:
“C++ : How to Program”, by Deitel & , Deitel 7 th Edition
2010.
In 1983, it was renamed from C with Classes to C . New features were added
virtual functions
function name operator overloading,
references, constants, type-safe free-store memory allocation (new/delete),
improved type checking, and BCPL style single-line comments with two forward
slashes (//), as well as the development of a proper compiler for C++, Cfront.
In 1985, the first edition of The C++ Programming Language was released,
which became the definitive reference for the language, as there was not yet
an official standard.[8]The first commercial implementation of C++ was
released in October of the same year. [5]
In 1989 C++ 2.0 was released followed by the updated second edition of The
C++ Programming Language in 1991.
This work became the basis for the future standard. Late feature additions
included templates, exceptions, namespaces, new casts, and a boolean type.
In 2011, C++11 was released which added more features and enlarged the
standard library further (compared to it in 1998), providing more facilities
for C++ programmers to use, with more additions
planned for 2014 and 2017 .
Structure of C++ Programs
Consists of Three main parts
Preprocessor Directives
C++ Statement
Preprocessor Directives
The instruction that are given to the complier before
the beginning of the actual program
Example:
#include <iostream.h>
main()
{
cout<<“Hello World”;
}
Header File
Header file is a c++ source file that contains definitions
of library function/objects.
Syntax
Main()
{
Program statements……
}
Variables
First character of variable name must be an alphabetic
character,
Underscore can be used as first character of variable name,
Blank spaces are not allowed in variable name.
Special characters, such as arithmetic operations, #,^,
cannot be used in a variable name.
Reserved words cannot be used as variable names.
Maximum length of a variable name depends upon the
compiler of c++.
Variable name declared for one data-type cannot be used to
declare another date-type.
Example
Variable Name Valid/Invalid Remarks
Nadeem valid
Perform Valid
Double invalid C++ reserved word
Foxpro Valid
Switch Invalid C++ reserved word
Marriam Valid
int invalid C++ reserved word
Unsigned invalid C++ reserved word
X-y invalid C++ reserved word
Date types
Type Size
Int 16 bits
Short int 16 bits
Long int 32 bits
Unsigned int 16 bits
Unsigned long int 32 bits
Float 32 bits
Long float 64 bits
double 64 bits
Long double 80 bits
Char 8 bits
Declaration of Variable
Assigning the name and data type that a variable can
hold is called declaration of the variable.
Int a, xy;
Float b;
Char nm [15];
Double sum;
Initialization of Variables
Int a = 110, b = 60, c;
Example
#include <iostream.h>
Main()
{
Output:
Int abc = 4, b = 1997;
Float xy = 3.4; ALI
4
Char name [15] = “ALI”; 1997
Cout<<name<<endl; 3.4
Cout<<abc<<endl;
Cout<<b<<endl;
Cout<<xy<<endl;
}