Вы находитесь на странице: 1из 11

Lecture No.

2
Bilal Ashfaq Ahmed
First C Program

// Welcome program
#include<iostream.h>
main()
{
cout<<“ Welcome to UOL !”;
}
Escape Sequence
Syntax
The syntax of a programming language specifies the rules for
creating a proper program in that language.

Errors &Types
C++ keywords
• Predefined special purpose word
• Know as ‘Reserved word’
• Can’t be used as variable or function name
C++Keywords
Keywordscommontothe
CandC++programming
languages
auto break case char const
continue default do double else
enum extern float for goto
if int long register return
short signed sizeof static struct
switch typedef union unsi gned void
volatile while
C++onlykeywords
asm bool catch class const_cast
delete dynamic_cast explicit false friend
inline mutable namespace new operator
private protected public reinterpret_cast
static_cast template this throw true
try ty peid typename using virtual
wchar_t
Variable
Variable is the name of a location in the memory

.
ABC

0002 3453
Rules of Variable
The name of a variable, its identifier, can be
composed of letters, digits, and the
underscore character.
Variable starts with
1. Character
2. Underscore ‘_’ (Not Recommended)
Variable
In a program every variable has
1. Name
2. Type
3. Size
4. Value
Assignment Operator
“=”
Assignment operator is a binary operator (a binary
operator has two operands).
Assign values to the two variables
Causes the value on the right to be assigned to the
variable on the left.
The = in C++ is equivalent to the := in Pascal or the = in
BASIC.
E.g. X = 5, X = 10 + 5, and X = X +1.
Data Types
A variable must have a data type associated with it, for example it
can have data types like integer, decimal numbers, characters etc.
The variable of type Integer stores integer values and a character
type variable stores character value. The primary difference between
various data types is their size in memory. Different data types have
different size in memory depending on the machine and compilers.
Five basic types
 int
 float
 double
 char
 void

Вам также может понравиться