110 likes | 185 Views
Computer Programming Code: CS1112. Lecture No. 2 Bilal Ashfaq Ahmed. First C Program. // Welcome program #include<iostream.h> main() { cout<<“ Welcome to UOL !”; }. Escape Sequence. Syntax. Errors &Types.
E N D
Computer ProgrammingCode: CS1112 Lecture No. 2 Bilal Ashfaq Ahmed
First C Program // Welcome program #include<iostream.h> main() { cout<<“ Welcome to UOL !”; }
Syntax Errors &Types The syntax of a programming language specifies the rules for creating a proper program in that language.
C++ keywords • Predefined special purpose word • Know as ‘Reserved word’ • Can’t be used as variable or function name
Variable Variable is the name of a location in the memory . • ABC 3453 • 0002
Rules of Variable The name of a variable, its identifier, can be composed of letters, digits, and the underscore character. Variable starts with • Character • Underscore ‘_’ (Not Recommended)
Variable In a program every variable has • Name • Type • Size • 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