Programming Fundamentals: 4.00 Credit Hours, Fall 2015, Undergraduate Program
Programming Fundamentals: 4.00 Credit Hours, Fall 2015, Undergraduate Program
Programming Fundamentals
4.00 Credit Hours, Fall 2015,
Undergraduate Program
Instructor: Maryam Ehsan
Learning C/C++
2
Today’s lecture outline
C character set
Basic constants and variables
3
C Character Set
4
Constants
An entity that doesn’t change
5
Integer Constants
Must have at least one digit
It must not have a decimal point
It can be either positive or negative
If there is no sign an integer constant is assumed to
be positive
No commas or blanks are allowed within an integer
constant
Examples: 135, -67, 3401, -5670
6
Real Constants
Also called Floating Point constants
A real constant must have at least one digit
It must have a decimal point
It could be either positive or negative
Default sign is positive
No commas or blanks are allowed within a real
constant
Examples: +325.34, 426.0, -32.76, -48.5792
7
Character Constants
A character constant is a
single alphabet
a single digit
or a single special symbol
Enclosed within single inverted commas
Both the inverted commas should point to the left
The maximum length can be 1 character
Examples: ’A’, ‘I’, ‘5’, ‘=‘
8
Variables…
An entity that may vary during program execution
Names given to locations in memory
x=3 x=5
9
Variables..
No commas or blanks are allowed within a variable
name.
No Special symbol are used in name.
Examples: Interger1, Sum, _FirstNum
Invalid variable names
#sum, 12x, first name
10
Variable Types
11
Keywords
Meaning already explained to compiler
Cannot be used as variable name
12