1 00:00:00,540 --> 00:00:01,320 In C plus. 2 00:00:01,320 --> 00:00:06,180 Plus the code is executed from the main function. 3 00:00:06,750 --> 00:00:11,550 So the function itself is a collection of statements to perform a specific task. 4 00:00:11,580 --> 00:00:21,000 As a result of this, a program in C plus plus has to contain at least one function named Main. 5 00:00:21,810 --> 00:00:28,560 So this code is the simplest program in C plus plus that will be successfully compiled and run. 6 00:00:28,560 --> 00:00:33,510 So suppose this code is saved in the main dot cpp file. 7 00:00:33,510 --> 00:00:40,640 We can compile the code using the g plus plus compiler by running the command here, g plus plus G, 8 00:00:40,650 --> 00:00:46,080 sym or main.cpp here and then a dot exe. 9 00:00:46,110 --> 00:00:50,600 So whenever we compile something, we're going to get the a dot exe file. 10 00:00:50,610 --> 00:00:57,630 So if we make it here, here, and as you can see here, our file is created right here. 11 00:00:57,630 --> 00:01:00,360 So now we're going to execute it a dot exe. 12 00:01:00,450 --> 00:01:06,030 And as you can see, this is our hello world that we executed from here. 13 00:01:06,180 --> 00:01:11,320 So if an error message appears, the output file will be generated automatically. 14 00:01:11,340 --> 00:01:19,050 So if we run this code compiling command in the windows console, we will get a file named a dot exe 15 00:01:19,290 --> 00:01:21,120 as I said earlier. 16 00:01:21,120 --> 00:01:27,880 So however, if we run the command on the bash shells such as Linux or Mac OS, we will get the file 17 00:01:27,880 --> 00:01:30,580 name named a dot out. 18 00:01:31,570 --> 00:01:39,640 So we can specify the output file name using the dot or option dot or option followed by the desired 19 00:01:39,640 --> 00:01:40,010 file name. 20 00:01:40,030 --> 00:01:49,090 For instance, if the command will write like this here Main.cpp dot minus all here and here, we're 21 00:01:49,090 --> 00:01:55,600 going to make it hoxily dot x and now we're going to make it here. 22 00:01:55,600 --> 00:01:55,870 Here. 23 00:01:55,870 --> 00:02:02,170 And as you can see here, our file name named Hoxily dot X is created right here. 24 00:02:02,170 --> 00:02:10,270 So whenever the dot x oops, hoxily dot x, and as you can see here, our file executed without any 25 00:02:10,270 --> 00:02:10,660 problem. 26 00:02:10,660 --> 00:02:15,190 And as you can see, the actual these are the same size of program because they are the same program 27 00:02:15,190 --> 00:02:16,450 but different file name. 28 00:02:17,490 --> 00:02:25,950 So indeed we run the output file by typing a and then pressing enter on the Windows console or by typing 29 00:02:25,950 --> 00:02:28,440 the auxiliary and then enter on a bash shell. 30 00:02:28,470 --> 00:02:34,020 We won't see anything on the console window if we don't have the stdcout here. 31 00:02:34,020 --> 00:02:44,010 So if we will delete that and make it GCC or g++ main.cpp and a dot exe. 32 00:02:44,010 --> 00:02:51,570 And as you can see, we have we see nothing here because we don't set anything to our program cpp file. 33 00:02:51,600 --> 00:02:53,100 To write something on the screen. 34 00:02:53,100 --> 00:02:56,810 So this is why it's not showing anything now. 35 00:02:56,820 --> 00:02:57,720 So. 36 00:02:59,090 --> 00:03:01,490 If a write like this for example. 37 00:03:01,880 --> 00:03:04,940 Integer E integer E here. 38 00:03:05,420 --> 00:03:05,930 STD. 39 00:03:07,640 --> 00:03:08,360 Let's see. 40 00:03:08,360 --> 00:03:08,750 Out. 41 00:03:10,320 --> 00:03:15,480 Please enter an integer value. 42 00:03:17,460 --> 00:03:18,870 And here. 43 00:03:19,590 --> 00:03:20,040 STD. 44 00:03:24,410 --> 00:03:31,460 Seen here is the and we're going to make it to E here and then STD. 45 00:03:32,640 --> 00:03:33,630 See out. 46 00:03:33,660 --> 00:03:35,280 This is the here. 47 00:03:36,000 --> 00:03:40,590 The value you entered is. 48 00:03:42,460 --> 00:03:48,580 Here, and then we're going to, uh, make it the new line. 49 00:03:49,270 --> 00:03:51,130 Stdcout. 50 00:03:52,160 --> 00:03:53,090 And. 51 00:03:53,090 --> 00:03:53,690 And here. 52 00:03:53,690 --> 00:03:54,500 Like this. 53 00:03:55,780 --> 00:03:56,710 So. 54 00:03:56,740 --> 00:03:57,380 Oops. 55 00:03:57,400 --> 00:03:58,000 Uh, the. 56 00:03:59,290 --> 00:04:03,010 Okay, So in here like this, let me check if the. 57 00:04:03,920 --> 00:04:04,430 Okay. 58 00:04:05,350 --> 00:04:06,070 So. 59 00:04:07,620 --> 00:04:11,220 Now let's run our program here. 60 00:04:12,110 --> 00:04:14,270 And save it. 61 00:04:15,210 --> 00:04:24,260 G Plus, plus, plus, plus main.cpp here and a dot xm this is. 62 00:04:24,260 --> 00:04:28,070 And please enter an integer value in this case 99. 63 00:04:28,070 --> 00:04:33,260 And as you can see here, the value is entered is 99. 64 00:04:33,260 --> 00:04:34,700 So this is just a basic example. 65 00:04:34,700 --> 00:04:40,250 So as you can see here, we appended several lines of code so that the program can print to the console 66 00:04:40,250 --> 00:04:42,650 and the user can give an input to the program. 67 00:04:42,650 --> 00:04:48,260 So initially the program displays text that ask the user to input an integer number. 68 00:04:48,260 --> 00:04:54,620 So after the user types, the desired number and then press enter, the program will print that number. 69 00:04:54,620 --> 00:04:58,640 So we will also define a new variable named E here. 70 00:04:58,670 --> 00:05:03,620 So this is the E of the integer data type. 71 00:05:03,620 --> 00:05:09,410 So this variable is used to store the data in integer data format. 72 00:05:09,410 --> 00:05:14,520 So we will talk about the variables and data types in next lecture. 73 00:05:14,520 --> 00:05:19,440 So here and this you can see here and then here. 74 00:05:20,690 --> 00:05:26,090 So suppose we have the same, um, the presenting code as the main dot cpp. 75 00:05:26,120 --> 00:05:32,600 We can compile it using the g plus plus the main dot cpp. 76 00:05:32,990 --> 00:05:35,810 And as you can see here, and run it like this. 77 00:05:35,810 --> 00:05:41,600 And you can also use the arrow here or parameter or in this case we're going to make it. 78 00:05:41,600 --> 00:05:48,910 For example, show number, show number dot exit and show number dot x. 79 00:05:48,920 --> 00:05:54,140 And as you can see here, uh, 77, the value you entered is 77. 80 00:05:54,440 --> 00:06:02,720 Uh, so now we now know that, uh, the print text to the console, we use the Stdcout command and to 81 00:06:02,720 --> 00:06:08,390 give some inputs to the program, we use the STD sin command here. 82 00:06:08,390 --> 00:06:14,630 So in this file we also see the include Iostream at the beginning of the file, it's used to tell the 83 00:06:14,630 --> 00:06:23,010 compiler where to find the implementation of the Stdcout at and std seen here. 84 00:06:23,950 --> 00:06:24,450 Oops. 85 00:06:24,460 --> 00:06:25,060 Yeah. 86 00:06:26,650 --> 00:06:29,200 So um. 87 00:06:29,200 --> 00:06:34,180 And since their implementation in is stated in the iOS stream file. 88 00:06:34,180 --> 00:06:38,050 So if you delete the stream file, you will see errors in this code. 89 00:06:38,050 --> 00:06:43,540 So since they are not the default here, so we need to input output stream here. 90 00:06:43,540 --> 00:06:48,190 So at the very beginning of the file we can see the. 91 00:06:49,140 --> 00:06:55,680 Lines here that begins, For example, actually, let's write some lines and I want to mention it. 92 00:06:56,430 --> 00:07:00,510 Comments here or Main.cpp Command. 93 00:07:01,170 --> 00:07:02,790 Oxley Academy. 94 00:07:02,790 --> 00:07:03,810 So here. 95 00:07:06,200 --> 00:07:08,540 So this is the double slashes. 96 00:07:08,540 --> 00:07:14,060 So this means that a line won't be considered as a code, so the compiler will ignore it. 97 00:07:14,060 --> 00:07:20,240 So it's used to comment or mark an action in the code so that other programmers can understand our code 98 00:07:20,270 --> 00:07:20,750 here. 99 00:07:20,750 --> 00:07:27,260 So if we compile this, you will get the same result because and the same file size because this code 100 00:07:27,260 --> 00:07:29,810 will ignore by the compiler. 101 00:07:29,810 --> 00:07:37,550 So let's actually make this so the writing so much comments like this should increase the file size. 102 00:07:37,550 --> 00:07:37,970 Right? 103 00:07:37,970 --> 00:07:47,780 So main dot CP here and with comments x and there here. 104 00:07:47,780 --> 00:07:54,680 And as you can see here, the show number is without comments, without comments. 105 00:07:54,830 --> 00:07:59,600 But the with comments here is with comments that we will write it like this. 106 00:07:59,600 --> 00:08:07,830 So and as you can see, the file size is same because the compiler isn't compiled this line of code. 107 00:08:07,830 --> 00:08:10,320 So this is just an a comment.