A1258561351PeLRM - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

A1258561351PeLRM

Description:

METALANGUAGE a language that is used to write the syntax rules for another language. OLDEST METALANGUAGE BNF (Backus-Naur Form) ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 15
Provided by: cjen7
Category:

less

Transcript and Presenter's Notes

Title: A1258561351PeLRM


1
include ltiostreamgt using namespace std int
Square ( int ) int Cube ( int ) int main
() coutltltThe square of 27 is ltlt Square(27)
ltlt endl coutltltThe cube of 27 is ltlt Cube(27)
ltlt endl return 0
2
SYNTAX defines exactly what combination of
letters, numbers and symbols can be
used SEMANTICS a set of rules that determines
the meaning of instructions METALANGUAGE a
language that is used to write the syntax rules
for another language OLDEST METALANGUAGE BNF
(Backus-Naur Form) SYNTAX TEMPLATE a generic
example of the c construct
3
IDENTIFIERS Identifier A name associated with a
function or data object and used to refer to that
function or data object Rules a) must start
with a letter or an underscore b) identifiers
that begin with underscore have special
meaning Invalid Identifier Explanation 40Hours
Identifiers cannot begin with a digit Get
Data Blanks are not allowed Box-22 hyphen is
a math symbol Cost_in_ () special symbols
are not allowed int reserved word
4
Valid Identifier How it is used MAX_HOURS Maximu
m normal work hours OVERTIME Overtime pay rate
factor payRate An employees hourly pay
rate hours number of hours an employee
worked wages employees weekly
wages empNum An employees identification
number CalcPay a function for computing an
employees wages
5
C IS CASE SENSATIVE EmpNum is not the same as
empnum Emp Num is not the same as EmpNum empNum
is not the same as EmpNum
6
  • DATA TYPES
  • TWO CATEGORIES OF DATA TYPES
  • STANDARD OR BUILT IN use often so C has them
    predefined
  • int float char
  • Programmer or user defined data types see
    chapter 10.

7
  • HOW DATA IS STORED IN MEMORY
  • Memory is divided into CELLS
  • Each CELL has a unique address
  • This address is a binary number
  • We use identifiers to name cells
  • The compiler translates the identifier into the
    address in memory

Cell 1101101101
Cell 1101101111
Cell 1101101000
EmpNum
EmpPay
EmpAddress
8
Char char consists of one alphanumeric
character a letter, digit or special
symbol char is enclosed is a singe quote 8 8
? 8 8 is an alphanumeric cannot be used in
mathematical equations 8 is a numeric can be
used in mathematical equations is a blank
char it consists of a press the space bar
A lt B due to a predefined collating
sequence but we cannot do math on chars
9
String String a sequence of characters word,
name, sentence Strings are enclosed in double
quotes. I am happy Strings must be typed on
one line dont split. I am Happy will give
you an error. is the empty string or null
string no space between double quotes
10
DATA OBJECTS CONSTANTS a name of a memory
location whose contents are not allowed to
change VARIABLES a name of a memory location
whose contents can change
const char EMPCODE
int EmpNum
A
1001 1002
11
DECLARATION Declaration a statement that
associates an identifier with a data object, a
function or a data type so that the programmer
can refer to the item by name int EmpNum int
EmpPay const char EMPCODE A int Square(
int)
12
Variables a location in memory, referenced by
an identifier, that contains a data value that
can be changed Declaring a variable specify
data type and name int EmpNum int
EmpPay string EmpAddress OR int EmpNum,
EmpPay string EmpAddress
int EmpNum
int EmpPay
string EmpAddress
13
Constants a location in memory, referenced by
an identifier, that contains a data value that
CANNOT be changed Declaring a constant specify
constant, data type, name and data value const
char EMPCODE A
const char EMPCODE
A
14
LITERAL VS CONSTANT LITERAL any constant value
written in a program coutltltI am a c
programmer NAMED CONSTANT const char EMPCODE
LITERAL VALUE
Write a Comment
User Comments (0)
About PowerShow.com