1 00:00:05,020 --> 00:00:13,720 As discussed in previous lectures, a type declares how an object will be interpreted and used by the 2 00:00:13,720 --> 00:00:14,590 compiler. 3 00:00:15,040 --> 00:00:18,910 Every object in C++ program has a type. 4 00:00:19,720 --> 00:00:27,100 This lecture begins with a broader discussion of fundamental types and then introduce user defined types. 5 00:00:27,130 --> 00:00:31,030 Along the way, you will learn about the several control flow of structures. 6 00:00:31,450 --> 00:00:34,870 So let's get started by fundamental types here. 7 00:00:34,900 --> 00:00:43,870 So fundamental types are the most basic types of object and include integer floating point, character, 8 00:00:43,870 --> 00:00:48,790 boolean, bite size, TX and void. 9 00:00:50,350 --> 00:00:50,790 Here. 10 00:00:50,800 --> 00:00:51,850 So. 11 00:00:54,920 --> 00:00:59,750 Some refer to functional mental types as a primitive or built in types because they are part of the 12 00:00:59,750 --> 00:01:03,110 core language and almost always available to you. 13 00:01:03,500 --> 00:01:10,280 So these types will work on any platform, but their features such as size and memory layout, depend 14 00:01:10,280 --> 00:01:12,080 on the implementation. 15 00:01:12,080 --> 00:01:15,410 So fundamental types strike a balance. 16 00:01:15,500 --> 00:01:23,900 On one hand, they try to map a direct relationship from C++ construct to computer hardware. 17 00:01:23,900 --> 00:01:30,920 So on the other hand, they simplify writing cross-platform code, allowing a programmer to write code 18 00:01:30,920 --> 00:01:33,320 ones that works on many platforms. 19 00:01:33,710 --> 00:01:38,210 The section that follows provide additional detail about these fundamental types. 20 00:01:38,570 --> 00:01:40,100 So let's get started. 21 00:01:40,460 --> 00:01:43,430 Integer with integer types here. 22 00:01:46,010 --> 00:01:47,420 So integer types. 23 00:01:49,250 --> 00:01:52,610 The integer types here. 24 00:01:52,790 --> 00:01:55,350 Let me open the another picture here. 25 00:01:55,370 --> 00:01:57,470 So this is the integer data types. 26 00:01:57,740 --> 00:02:05,270 So integer data type store who numbers that you can write without the fractional component. 27 00:02:05,840 --> 00:02:10,430 The four size of integer types are brought integer. 28 00:02:11,790 --> 00:02:13,230 Unsigned short integer. 29 00:02:13,260 --> 00:02:16,200 Actually, these are the four types here. 30 00:02:16,500 --> 00:02:22,270 I will not count unsigned as a type. 31 00:02:22,290 --> 00:02:25,110 So short integer integer. 32 00:02:25,680 --> 00:02:29,610 Long integer and long long integer. 33 00:02:29,640 --> 00:02:35,970 Of course, all of them has an unsigned type, which I will explain later. 34 00:02:36,300 --> 00:02:38,040 What these inside types are. 35 00:02:38,070 --> 00:02:43,830 So assigned variable here sign variable can be positive. 36 00:02:44,660 --> 00:02:47,330 Negative year or zero. 37 00:02:53,030 --> 00:02:59,400 And the sine variable must be non negative. 38 00:02:59,420 --> 00:03:06,410 As you can see, our typical range from the short integer your starts with a negative number and continues 39 00:03:06,410 --> 00:03:11,840 to positive number, but has the less positive and the less negative. 40 00:03:11,840 --> 00:03:19,250 But if you will use if you want to use only positive numbers, then unsigned integers is for you. 41 00:03:20,000 --> 00:03:25,910 So integers types are signed by signed and integer by default. 42 00:03:25,910 --> 00:03:33,590 As you can see, when you put an integer, create an integer variable, you will create an. 43 00:03:34,640 --> 00:03:41,550 Sign typing to George so you can store both negative and positive numbers. 44 00:03:49,240 --> 00:03:51,190 Take a look at this picture here. 45 00:03:53,210 --> 00:03:58,430 So notice that the integer type size varies across platforms. 46 00:03:59,000 --> 00:04:10,430 For example, 4464 bit Windows and Linux have different size for a long integer four or eight respectively. 47 00:04:11,570 --> 00:04:19,370 So usually a compiler will warn you of a mismatch between format specified and integer type, but you 48 00:04:19,370 --> 00:04:26,570 must ensure that the format specifiers are correct when you are using them in printf statements. 49 00:04:26,570 --> 00:04:33,890 So format specifiers appear here so you can print integers to console in examples. 50 00:04:34,460 --> 00:04:35,660 Follow here. 51 00:04:35,690 --> 00:04:39,500 So let's get started by creating some examples here. 52 00:04:39,500 --> 00:04:42,500 So a literal hardcoded value in program. 53 00:04:42,500 --> 00:04:48,800 Here you can use one of four hardcoded integer literal representations. 54 00:04:50,420 --> 00:04:51,020 Here. 55 00:04:51,050 --> 00:05:00,500 The first is binary binary users, the users, the prefix users, the fix. 56 00:05:02,400 --> 00:05:03,910 Six zero. 57 00:05:03,930 --> 00:05:05,240 Be near. 58 00:05:07,180 --> 00:05:08,530 The octal. 59 00:05:10,490 --> 00:05:15,380 Uses the prefix zero the decimal. 60 00:05:16,790 --> 00:05:17,810 Decimal. 61 00:05:18,740 --> 00:05:20,090 This is default. 62 00:05:22,200 --> 00:05:24,300 And the hexadecimal. 63 00:05:26,560 --> 00:05:32,650 Uses the prefix uses the prefix zero x. 64 00:05:33,710 --> 00:05:40,280 So these are the four different ways of writing the same set of numbers. 65 00:05:41,030 --> 00:05:43,880 For example, I will. 66 00:05:44,580 --> 00:05:46,110 Write some code here. 67 00:05:48,480 --> 00:05:50,690 Which I will show you. 68 00:05:50,930 --> 00:05:57,530 You might assign several integer variables with an integer literal using each of the non decimal representations 69 00:05:57,530 --> 00:05:58,080 here. 70 00:05:58,160 --> 00:06:00,050 So let's get started here. 71 00:06:00,500 --> 00:06:10,370 Let's get an unsigned unsigned short A equals zero B be actual. 72 00:06:10,580 --> 00:06:11,360 Let me. 73 00:06:13,140 --> 00:06:17,070 Just control the idea so you can see what we write here. 74 00:06:18,130 --> 00:06:18,970 So. 75 00:06:20,620 --> 00:06:30,640 A unsigned, unsigned, unsigned integer and unsigned short A equals zero. 76 00:06:30,640 --> 00:06:31,150 B. 77 00:06:31,510 --> 00:06:32,050 Ten. 78 00:06:32,050 --> 00:06:32,530 Ten. 79 00:06:32,530 --> 00:06:32,980 Ten. 80 00:06:32,980 --> 00:06:33,550 Ten. 81 00:06:34,560 --> 00:06:39,900 I will explain all of these courts later, like after we done this. 82 00:06:39,930 --> 00:06:40,890 I will explain this. 83 00:06:43,350 --> 00:06:44,020 Plaintiff. 84 00:06:47,520 --> 00:06:53,550 So you and then new line A. 85 00:06:55,650 --> 00:06:59,520 And then let's create another variable, which is integer. 86 00:06:59,520 --> 00:07:00,080 Integer. 87 00:07:00,090 --> 00:07:01,230 Be zero. 88 00:07:01,230 --> 00:07:02,370 One, two, three. 89 00:07:02,400 --> 00:07:04,320 I will explain this later. 90 00:07:04,770 --> 00:07:05,790 Print F. 91 00:07:08,030 --> 00:07:17,300 The with present operator and new line and we will gave this to be. 92 00:07:19,650 --> 00:07:21,450 And one unsigned. 93 00:07:25,870 --> 00:07:27,940 Long long the. 94 00:07:30,710 --> 00:07:38,840 The r0x as we use the hexadecimal here uses the prefix zero x. 95 00:07:40,490 --> 00:07:42,920 Here, for example, like a. 96 00:07:44,130 --> 00:07:49,500 One, two, three, four, five, six, seven, eight, nine, ten, 11, 12, 13. 97 00:07:50,910 --> 00:07:51,480 Your. 98 00:07:55,310 --> 00:07:58,400 And the princess value as well. 99 00:07:58,790 --> 00:07:59,800 Princess. 100 00:08:01,730 --> 00:08:05,900 You will learn about Formants specifiers as well in later lectures. 101 00:08:07,150 --> 00:08:09,980 Thank you. 102 00:08:09,980 --> 00:08:11,270 And new line. 103 00:08:12,850 --> 00:08:13,210 It's. 104 00:08:15,530 --> 00:08:26,630 Bellevue and New Line of New line and gave this number the right yet the here and then. 105 00:08:28,110 --> 00:08:30,180 We are ready to compile this. 106 00:08:31,250 --> 00:08:34,390 Which I will explain all of this culture here. 107 00:08:35,850 --> 00:08:40,410 She says Our code is compiled without any errors. 108 00:08:42,090 --> 00:08:42,810 Here. 109 00:08:42,870 --> 00:08:45,150 And let's run this quote here. 110 00:08:46,250 --> 00:08:46,760 Oops. 111 00:08:47,370 --> 00:08:48,850 Oh, we have to save this here. 112 00:08:48,860 --> 00:08:52,130 And let's compile code again and again. 113 00:08:52,640 --> 00:08:56,120 Compile within without any errors here. 114 00:08:56,630 --> 00:09:02,390 So as you can see here, the first number is 107. 115 00:09:04,100 --> 00:09:06,860 The second number is 83. 116 00:09:08,100 --> 00:09:13,740 When you convert them to decimal, throw them in decimal arrange. 117 00:09:14,070 --> 00:09:20,600 And the last numbers that we wrote with hexadecimal numbers is like something like that. 118 00:09:20,820 --> 00:09:21,870 This is the decimal point. 119 00:09:21,900 --> 00:09:24,270 Not like any other weird numbers. 120 00:09:24,990 --> 00:09:25,740 So. 121 00:09:27,130 --> 00:09:29,380 The first is binary. 122 00:09:30,740 --> 00:09:36,950 So this program uses each of the non decimal integer representations versus binary. 123 00:09:37,280 --> 00:09:38,630 Second is octal. 124 00:09:39,020 --> 00:09:47,250 And the third is hexadecimal and prints, each with the printf using the appropriate format specified 125 00:09:47,360 --> 00:09:50,200 listed in previous lectures. 126 00:09:50,210 --> 00:09:54,660 So the output from each print period. 127 00:09:54,680 --> 00:09:56,720 Here as you can see here. 128 00:09:57,840 --> 00:09:58,650 So. 129 00:10:10,860 --> 00:10:15,960 Let me pause the video so we can change to the next lecture. 130 00:10:17,100 --> 00:10:19,680 And I'm waiting you in the next lecture. 131 00:10:19,710 --> 00:10:20,310 See you.