WEBVTT

00:00.540 --> 00:01.320
In C plus.

00:01.320 --> 00:06.180
Plus the code is executed from the main function.

00:06.750 --> 00:11.550
So the function itself is a collection of statements to perform a specific task.

00:11.580 --> 00:21.000
As a result of this, a program in C plus plus has to contain at least one function named Main.

00:21.810 --> 00:28.560
So this code is the simplest program in C plus plus that will be successfully compiled and run.

00:28.560 --> 00:33.510
So suppose this code is saved in the main dot cpp file.

00:33.510 --> 00:40.640
We can compile the code using the g plus plus compiler by running the command here, g plus plus G,

00:40.650 --> 00:46.080
sym or main.cpp here and then a dot exe.

00:46.110 --> 00:50.600
So whenever we compile something, we're going to get the a dot exe file.

00:50.610 --> 00:57.630
So if we make it here, here, and as you can see here, our file is created right here.

00:57.630 --> 01:00.360
So now we're going to execute it a dot exe.

01:00.450 --> 01:06.030
And as you can see, this is our hello world that we executed from here.

01:06.180 --> 01:11.320
So if an error message appears, the output file will be generated automatically.

01:11.340 --> 01:19.050
So if we run this code compiling command in the windows console, we will get a file named a dot exe

01:19.290 --> 01:21.120
as I said earlier.

01:21.120 --> 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

01:27.880 --> 01:30.580
name named a dot out.

01:31.570 --> 01:39.640
So we can specify the output file name using the dot or option dot or option followed by the desired

01:39.640 --> 01:40.010
file name.

01:40.030 --> 01:49.090
For instance, if the command will write like this here Main.cpp dot minus all here and here, we're

01:49.090 --> 01:55.600
going to make it hoxily dot x and now we're going to make it here.

01:55.600 --> 01:55.870
Here.

01:55.870 --> 02:02.170
And as you can see here, our file name named Hoxily dot X is created right here.

02:02.170 --> 02:10.270
So whenever the dot x oops, hoxily dot x, and as you can see here, our file executed without any

02:10.270 --> 02:10.660
problem.

02:10.660 --> 02:15.190
And as you can see, the actual these are the same size of program because they are the same program

02:15.190 --> 02:16.450
but different file name.

02:17.490 --> 02:25.950
So indeed we run the output file by typing a and then pressing enter on the Windows console or by typing

02:25.950 --> 02:28.440
the auxiliary and then enter on a bash shell.

02:28.470 --> 02:34.020
We won't see anything on the console window if we don't have the stdcout here.

02:34.020 --> 02:44.010
So if we will delete that and make it GCC or g++ main.cpp and a dot exe.

02:44.010 --> 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.

02:51.600 --> 02:53.100
To write something on the screen.

02:53.100 --> 02:56.810
So this is why it's not showing anything now.

02:56.820 --> 02:57.720
So.

02:59.090 --> 03:01.490
If a write like this for example.

03:01.880 --> 03:04.940
Integer E integer E here.

03:05.420 --> 03:05.930
STD.

03:07.640 --> 03:08.360
Let's see.

03:08.360 --> 03:08.750
Out.

03:10.320 --> 03:15.480
Please enter an integer value.

03:17.460 --> 03:18.870
And here.

03:19.590 --> 03:20.040
STD.

03:24.410 --> 03:31.460
Seen here is the and we're going to make it to E here and then STD.

03:32.640 --> 03:33.630
See out.

03:33.660 --> 03:35.280
This is the here.

03:36.000 --> 03:40.590
The value you entered is.

03:42.460 --> 03:48.580
Here, and then we're going to, uh, make it the new line.

03:49.270 --> 03:51.130
Stdcout.

03:52.160 --> 03:53.090
And.

03:53.090 --> 03:53.690
And here.

03:53.690 --> 03:54.500
Like this.

03:55.780 --> 03:56.710
So.

03:56.740 --> 03:57.380
Oops.

03:57.400 --> 03:58.000
Uh, the.

03:59.290 --> 04:03.010
Okay, So in here like this, let me check if the.

04:03.920 --> 04:04.430
Okay.

04:05.350 --> 04:06.070
So.

04:07.620 --> 04:11.220
Now let's run our program here.

04:12.110 --> 04:14.270
And save it.

04:15.210 --> 04:24.260
G Plus, plus, plus, plus main.cpp here and a dot xm this is.

04:24.260 --> 04:28.070
And please enter an integer value in this case 99.

04:28.070 --> 04:33.260
And as you can see here, the value is entered is 99.

04:33.260 --> 04:34.700
So this is just a basic example.

04:34.700 --> 04:40.250
So as you can see here, we appended several lines of code so that the program can print to the console

04:40.250 --> 04:42.650
and the user can give an input to the program.

04:42.650 --> 04:48.260
So initially the program displays text that ask the user to input an integer number.

04:48.260 --> 04:54.620
So after the user types, the desired number and then press enter, the program will print that number.

04:54.620 --> 04:58.640
So we will also define a new variable named E here.

04:58.670 --> 05:03.620
So this is the E of the integer data type.

05:03.620 --> 05:09.410
So this variable is used to store the data in integer data format.

05:09.410 --> 05:14.520
So we will talk about the variables and data types in next lecture.

05:14.520 --> 05:19.440
So here and this you can see here and then here.

05:20.690 --> 05:26.090
So suppose we have the same, um, the presenting code as the main dot cpp.

05:26.120 --> 05:32.600
We can compile it using the g plus plus the main dot cpp.

05:32.990 --> 05:35.810
And as you can see here, and run it like this.

05:35.810 --> 05:41.600
And you can also use the arrow here or parameter or in this case we're going to make it.

05:41.600 --> 05:48.910
For example, show number, show number dot exit and show number dot x.

05:48.920 --> 05:54.140
And as you can see here, uh, 77, the value you entered is 77.

05:54.440 --> 06:02.720
Uh, so now we now know that, uh, the print text to the console, we use the Stdcout command and to

06:02.720 --> 06:08.390
give some inputs to the program, we use the STD sin command here.

06:08.390 --> 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

06:14.630 --> 06:23.010
compiler where to find the implementation of the Stdcout at and std seen here.

06:23.950 --> 06:24.450
Oops.

06:24.460 --> 06:25.060
Yeah.

06:26.650 --> 06:29.200
So um.

06:29.200 --> 06:34.180
And since their implementation in is stated in the iOS stream file.

06:34.180 --> 06:38.050
So if you delete the stream file, you will see errors in this code.

06:38.050 --> 06:43.540
So since they are not the default here, so we need to input output stream here.

06:43.540 --> 06:48.190
So at the very beginning of the file we can see the.

06:49.140 --> 06:55.680
Lines here that begins, For example, actually, let's write some lines and I want to mention it.

06:56.430 --> 07:00.510
Comments here or Main.cpp Command.

07:01.170 --> 07:02.790
Oxley Academy.

07:02.790 --> 07:03.810
So here.

07:06.200 --> 07:08.540
So this is the double slashes.

07:08.540 --> 07:14.060
So this means that a line won't be considered as a code, so the compiler will ignore it.

07:14.060 --> 07:20.240
So it's used to comment or mark an action in the code so that other programmers can understand our code

07:20.270 --> 07:20.750
here.

07:20.750 --> 07:27.260
So if we compile this, you will get the same result because and the same file size because this code

07:27.260 --> 07:29.810
will ignore by the compiler.

07:29.810 --> 07:37.550
So let's actually make this so the writing so much comments like this should increase the file size.

07:37.550 --> 07:37.970
Right?

07:37.970 --> 07:47.780
So main dot CP here and with comments x and there here.

07:47.780 --> 07:54.680
And as you can see here, the show number is without comments, without comments.

07:54.830 --> 07:59.600
But the with comments here is with comments that we will write it like this.

07:59.600 --> 08:07.830
So and as you can see, the file size is same because the compiler isn't compiled this line of code.

08:07.830 --> 08:10.320
So this is just an a comment.
