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