Programming Fundamentals
Instructor : Ms. Momina Hafeez
Minhaj University
`
Switch off mobile phones during
lectures, or put them into silent mode
2
Grading Scheme
Class Tests / Quiz 10
Assignments 10
Presentation 05
Mid Term Test 25
Final Exam 50
DATA TYPES
Data types are means to identify the type of data and
associated operations of handling it. C++ provides a
predefined set of data types for handling the data it uses.
When variables are declared of a particular data type then
the variable becomes the place where the data is stored and
data types is the type of value(data) stored by that variable.
Data can be of may types such as character, integer, real etc.
since the data to be dealt with are of may types, a
programming language must provide different data types
DATA TYPES
Integer Data Type
Integers are whole numbers with a machine dependent
range of values. A good programming language as to support
the programmer by giving a control on a range of numbers
and storage space. C has 3 classes of integer storage namely
short int, int and long int. All of these data types have signed
and unsigned forms. A short int requires half the space than
normal integer values. Unsigned numbers are always
positive and consume all the bits for the magnitude of the
number. The long and unsigned integers are used to declare
a longer range of values.
Char Data Type
It can store any member of the C++
implementation's basic character set. If a character
from this set is stored in a character variable, its value is
equivalent to the integer code of that character. Character
data type is often called as integer data type because the
memory implementation of char data type is in terms of the
number code.
Float Data Type
A number having fractional part is a floating- point number.
An identifier declared as float becomes a floating-point
variable and can hold floating-point numbers. floating point
variables represent real numbers.
They have two advantages over integer data types:-
1: they can represent values between integers.
2: they can represent a much greater range of values.
they have one disadvantage also, that is their operations are
usually slower.
Double Data Type
The data type double is also used for handling floating-point
numbers. But it is treated as a distinct data type because, it
occupies twice as much memory as type float, and stores
floating-point numbers with much larger range and precision.
It is slower that type float.
Integer Type Modifier
C++ offers three types of integer data type:-
1:- short integer- at least two bytes.
2:- int integer – at least as big as short.
3:- long integer-at least four bytes.the prefix signed makes the
integer type hold negative values also. Unsigned makes the integer
not to hold negative values.
Char Type Modifier
The char can also be signed or unsigned. unlike int,char is not
signed or unsigned by default. It is later modified to best fit the type
to the hardware properties.
Floating Type Modifier
There are three floating-point types: float, double, and long double.
These types represent minimum allowable range of types.
Note:- don’t use commas in numeric values assigned to variables.
Links
https://www.dropbox.com/s/sec9qffiu7th22e/Dev-
Cpp%205.11%20TDM-GCC%204.9.2%20Setup.exe?dl=0
OR
https://sourceforge.net/projects/orwelldevcpp/
Thanks