As discussed in previous lectures, a type declares how an object will be interpreted and used by the
compiler.
Every object in C plus plus program has a type.
This lecture begins with a discussion of a fundamental types and then introduce user defined types.
Along the way, you will learn about the several control flow structures.
So let's get started by fundamental types here.
So fundamental types are the most basic types of object and include integer floating point, character,
boolean, byte size t and void.
Here.
So.
Some refer to fundamental types as primitive or built in types because they are part of the core language
and almost always available to you.
So these types will work on any platform, but the features such as size and memory layout depend on
the implementation.
So fundamental types strike a balance.
On one hand, they try to map a direct relationship from cplusplus construct to computer hardware.
So on the other hand, they simplify writing cross-platform code by allowing a programmer to write code
once that works on many platforms.
The section that follows provide additional detail about these fundamental types.
So let's get started.
Integer.
With integer types here.
So integer types.
The integer types here.
Let me open the another picture here.
So this is the integer data types.
So integer data types store whole numbers that you can write without a fractional component.
The four size of integer types are short integer.
Unsigned short integer.
Actually, these are the four types here.
I will not count the unsigned as a type.
So short integer.
Integer.
Long integer.
And long.
Long integer.
Of course, all of them has a unsigned type, which I will explain later.
What is inside types are so assign variable here.
Sign variable can be positive.
Negative here or zero?
And the unsigned variable must be a non-negative.
As you can see here, typical range from the short integer here starts with a negative number and continues
to positive number, but has the less positive and the less negative.
But if you will use if you want to use only positive numbers, then unsigned integers is for you.
So integer types are signed unsigned and integer by default.
As you can see, when you put an integer creating an integer variable, you will create an.
Signed type integer so you can store both negative and positive numbers.
Take a look at this picture here.
So notice that the integer type size vary across platforms.
For example, 4464 bit Windows and Linux have different size for long integer 4 or 8 respectively.
So usually a compiler will warn you of a mismatch between format specifier and integer type, but you
must ensure that the format specifiers are correct when you are using them in printf statements.
So format specifiers appear here so you can print integers to console in examples.
Follow here.
So let's get started by creating some examples here.
So literal hardcoded value in program here you can use one of four hardcoded integer literal representations.
Here.
The first is binary.
Binary uses the uses the prefix uses the prefix.
Mix.
Zero be here.
The octal.
Uses the prefix zero.
The decimal.
Decimal.
This is default.
And the hexadecimal.
Uses the prefix uses the prefix zero x.
So these are the four different ways of writing the same set of full numbers.
For example, I will.
Write some code here.
Uh, which I will show you.
You might assign several integer variables with an integer literal using each of the non-decimal representations
here.
So let's get started here.
Let's get unsigned.
Unsigned, short A equals zero B.
Actually, let me.
Just Ctrl Z there so you can see what we write here.
So.
Um, unsigned, unsigned, unsigned, short integer.
Unsigned.
Short.
A equals zero b.
Ten.
I will explain all of these codes later.
Like after we done this, I will explain these codes.
Printf.
Uh, okay.
So you and then new line A.
And then let's create another variable, which is integer integer zero, one, two, three.
I will explain this later.
Print f.
Um the with present operator and new line and we will give this to be.
An unsigned.
A long, long.
PR zero x as we use the hexadecimal here, use the prefix zero x.
Here, for example, like.
One, two, three, four, five, six, seven, eight, nine, ten, 11, 12, 13.
Here.
And print this value as well.
Print f.
You will learn about format specifiers as well in later lectures.
LL you and New line.
It's.
A value and new line ups new line and gave this number the right yeah the here and then.
Uh, we are ready to compile this.
Which I will explain all of these codes here.
Here.
Our code is compiled without any errors.
Here.
And let's run this code here.
Oops.
All we have to save this here.
And let's compile code again.
Again, compile with without any errors here.
So as you can see here, the first number is 107.
The second number is 83.
When you convert them to decimal, throw them in decimal range.
And the last numbers that we wrote with hexadecimal numbers is like something like that.
This is the decimal point, not like any other weird numbers.
So.
The first is binary.
So this program uses each of the non-decimal integer representations versus the binary.
Second is octal and the third is hexadecimal and prints each with the print f using the appropriate
format specifier listed in previous lectures.
So the output from each print appeared here, as you can see here.
So.
Let me pause the video so we can change to next lecture.
And I'm waiting you in next lecture.
See you.