0% found this document useful (0 votes)
5 views16 pages

Programming Fundamentals for Software Engineering

The document outlines the fundamentals of programming in C++, focusing on key concepts such as character sets, constants, variables, and keywords. It explains different types of constants (integer, real, and character), variable naming conventions, and the importance of data types in memory. Additionally, it emphasizes the necessity of declaring variables before use and clarifies the distinction between assignment operators and algebraic equality.

Uploaded by

zaidnazimmughal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

Programming Fundamentals for Software Engineering

The document outlines the fundamentals of programming in C++, focusing on key concepts such as character sets, constants, variables, and keywords. It explains different types of constants (integer, real, and character), variable naming conventions, and the importance of data types in memory. Additionally, it emphasizes the necessity of declaring variables before use and clarifies the distinction between assignment operators and algebraic equality.

Uploaded by

zaidnazimmughal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Course:

Programming Fundamentals
4.00 Credit Hours
Undergraduate Program

SESSION 1, 2

Week 2

© www.uskt.edu.pk
Learning C++

• Learning C++

• Character Set

• Constants

• Variables
++
• Keywords
Character Set

• Learning C++

• Character Set

• Constants

• Variables

• Keywords
Constants

• Learning C++
•An entity that doesn’t change
• Character Set

• Constants

• Variables

• Keywords
Constants
Integer Constants
• Learning C++

• Character Set • Must have at least one digit


• It must not have a decimal point
• Constants
• It can be either positive or negative
• Variables • If there is no sign an integer constant is
assumed to be positive
• Keywords
• No commas or blanks are allowed within
an integer constant
• Examples: 135, -67, 3401, -5670
Constants
Real Constants
• Learning C++
• Also called Floating Point constants
• Character Set • A real constant must have at least one
• Constants digit
• It must have a decimal point
• Variables
• It could be either positive or negative
• Keywords • Default sign is positive
• No commas or blanks are allowed within
a real constant
• Examples: +325.34, 426.0, -32.76, -
48.5792
Constants
Character Constants
• Learning C++

• Character Set • A character constant is a


• single alphabet
• Constants
• a single digit
• Variables • or a single special symbol
• Keywords
• 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’, ‘=‘
Variables

• Learning C++
• An entity that may vary during program
• Character Set execution
• Constants • Names given to locations in memory
• Variables

• Keywords x=3 x=5


Variables

• Learning C++
• Series of characters (letters, digits,
• Character Set underscores)
• Constants
• Must begin with a letter or underscore
• Variables

• Keywords • Case sensitive

• Meaningful naming scheme


Variables

• Learning C++
• No commas or blanks are allowed within
• Character Set a variable name.
• Constants
• No Special symbol are used in name.
• Variables

• Keywords • Examples: Interger1, Sum, _FirstNum

• Invalid variable names


• #sum, 12x, first name
Variables

• Learning C++
Every variable has
• Character Set

• Constants • Name
• Type
• Variables
• Size
• Keywords • Value
• Address
Variable declaration
• Any variable used in the program must
• Learning C++
be declared first before using it.
• Character Set

• Constants

• Variables

• Keywords
Variables
Assignment Operator
• Learning C++

• Character Set • Equal-to-sign i.e. = used as assignment


• Constants operator
• Don’t confuse Algebraic equal-to with
• Variables
the assignment operator in C++ language
• Keywords • For example, a = 2
In Algebra In C++ Language
• Value of a is 2 • a is a variable name
• Take the value 2 and put it in
memory location labeled as
a
Variables
Data Type
• Learning C++

• Character Set •A variable must have a data type


• Constants associated with it, for example
• integer
• Variables
• decimal
• Keywords • character etc.

• Primary difference between different


data type is their size in memory
Variables
Data Type
• Learning C++

• Character Set • Different data type have different size in


• Constants memory depending on the machine and
compilers.
• Variables

• Keywords • Affect the way they are displayed

• Few data types in C++ language which


are reserved words of C++ language.
Keywords
• Meaning already explained to compiler
• Learning C++

• Character Set • Cannot be used as variable name


• Constants

• Variables

• Keywords

You might also like