1 00:00:00,360 --> 00:00:06,690 So next part, this function declaration here is where we declare the function, we will introduce the 2 00:00:06,690 --> 00:00:10,140 compiler, our function with its definition. 3 00:00:10,560 --> 00:00:17,940 So suppose I am planning to add numbers three and five and I should have an option to create the function 4 00:00:17,940 --> 00:00:26,490 cards, some which accept this variables, let's say and b, and it should be only accepting integer 5 00:00:26,490 --> 00:00:28,500 numbers, not floating by numbers. 6 00:00:28,770 --> 00:00:30,900 So how should I define the function? 7 00:00:31,530 --> 00:00:35,760 So you, as you know, my function, is aimed at adding two numbers. 8 00:00:36,060 --> 00:00:40,590 So my function will always act on numbers and get another number. 9 00:00:40,620 --> 00:00:43,830 I set the static audits and indigena, but I say it isn't. 10 00:00:44,130 --> 00:00:47,790 If I am doing this, I will get that indigenous instead. 11 00:00:48,000 --> 00:00:53,840 So here it shows this is the return date, which means when this function is getting executed, that 12 00:00:54,060 --> 00:01:00,580 when the function name some is getting executed, that it will return a value with the return date int. 13 00:01:01,200 --> 00:01:07,140 Now this function named some will accept new variables for operations. 14 00:01:07,380 --> 00:01:12,930 It's a and b, so suppose if I am leaving like this some. 15 00:01:14,460 --> 00:01:16,080 Three comma, five. 16 00:01:17,840 --> 00:01:23,390 Exactly this function will exit three here on air and five here on B. 17 00:01:24,300 --> 00:01:27,660 Then what will happen, the rest of the card is included in this. 18 00:01:28,540 --> 00:01:33,330 So we will be putting a brace and giving the function definition. 19 00:01:33,600 --> 00:01:36,510 So here we are planning to see out of print. 20 00:01:36,960 --> 00:01:43,410 We are inside the some function and some may be that variable also have been declared yet. 21 00:01:43,620 --> 00:01:51,030 So here is three when I use this s Garling statement, this will be here and this will be B. 22 00:01:51,030 --> 00:01:52,320 So five plus three is eight. 23 00:01:52,500 --> 00:01:56,970 So here we have a written statement, which is eight, which will give that man. 24 00:01:57,240 --> 00:01:59,160 We have guard this support. 25 00:01:59,160 --> 00:02:04,910 I have got some e going to let it be in. 26 00:02:04,920 --> 00:02:08,830 Some may go to some or some function. 27 00:02:08,850 --> 00:02:14,610 This is some function, some of it comma certified comma three. 28 00:02:15,660 --> 00:02:22,050 Then it will be like going like this, so it will be calling this definition. 29 00:02:23,200 --> 00:02:24,110 It will be giving. 30 00:02:24,130 --> 00:02:26,580 Now I have changed about using that change the values. 31 00:02:26,920 --> 00:02:30,910 So anyway, some snake bodies equals anyway. 32 00:02:31,060 --> 00:02:33,280 This will be five and this will be three. 33 00:02:34,150 --> 00:02:38,990 Then it will be it is playing inside some function, then will be doing five plus three. 34 00:02:38,990 --> 00:02:42,120 It will be eight and then it will return some, he added. 35 00:02:42,490 --> 00:02:43,630 This is the return date. 36 00:02:44,080 --> 00:02:45,040 So what happens? 37 00:02:45,370 --> 00:02:49,550 It will return the value of something that is eight that will come out here. 38 00:02:49,570 --> 00:02:53,370 So the result will be some will be eight. 39 00:02:54,250 --> 00:03:00,490 And one more thing you have to note, I have declared to some media, which already had one is inside 40 00:03:00,490 --> 00:03:02,980 the function and one is outside the function. 41 00:03:03,430 --> 00:03:07,990 So both will be different because this variable was just declared inside. 42 00:03:07,990 --> 00:03:13,870 The function will be a local variable and the other one will be that variable out of scope. 43 00:03:13,990 --> 00:03:20,320 That means it may be able to be just defined inside the function well in its scope. 44 00:03:20,740 --> 00:03:24,040 Scope means its value will not be accessible. 45 00:03:24,280 --> 00:03:31,990 After we leave that particular function so it can be defined, all here will not be accessible beyond 46 00:03:31,990 --> 00:03:32,680 this function. 47 00:03:32,830 --> 00:03:34,360 It will be still that. 48 00:03:34,600 --> 00:03:40,330 So that's why we are returning this summer because some is deleted or some is removed from the memory 49 00:03:40,570 --> 00:03:42,670 just after this function has exited. 50 00:03:42,850 --> 00:03:48,220 So in order to proclaim that some variable or some value, we need to return that. 51 00:03:48,640 --> 00:03:52,660 And that's why we are using added turned back over here. 52 00:03:53,200 --> 00:03:54,280 Hope you have, I'm not sure. 53 00:03:54,430 --> 00:03:59,050 So there will be three important box which will be inside a function. 54 00:03:59,470 --> 00:04:05,380 Why this function declaration, which will show that return type of the function name of the function? 55 00:04:05,560 --> 00:04:10,870 The argument is accepted by the function any number of arguments function can, except suppose we can 56 00:04:10,870 --> 00:04:15,190 also create a function that accepts 10 number SoyNut. 57 00:04:16,930 --> 00:04:17,410 Some. 58 00:04:19,710 --> 00:04:30,570 India coal mine to be karma in the sea, etc. Likewise, we have we can divine any number of arguments 59 00:04:30,570 --> 00:04:39,360 and the function will be able to process that and modernise like air function can always avoid returning 60 00:04:39,360 --> 00:04:40,170 memories. 61 00:04:40,380 --> 00:04:42,470 This written statement is optional. 62 00:04:42,750 --> 00:04:50,700 Suppose if I don't want to return to some, I just want to print it right away here I can just put out 63 00:04:50,700 --> 00:04:51,270 a statement. 64 00:04:51,810 --> 00:04:58,710 But in the summer here and I can remove the statement, and if there is no written statement or return 65 00:04:58,710 --> 00:05:00,930 time, then they function. 66 00:05:01,200 --> 00:05:03,440 The return date should be void. 67 00:05:03,720 --> 00:05:04,500 That's it. 68 00:05:04,800 --> 00:05:06,210 That's the only thing I would do. 69 00:05:06,510 --> 00:05:07,200 Make sure. 70 00:05:08,770 --> 00:05:15,910 So anyway, I have explained to you everything on here, it says, anyway, began gems Typekit right 71 00:05:15,910 --> 00:05:18,630 away and do it smaller demand functions. 72 00:05:19,030 --> 00:05:21,550 So let's jump in visual studio code. 73 00:05:24,280 --> 00:05:26,280 So here I have a. 74 00:05:27,490 --> 00:05:34,990 Program created for you and scored fine, send out CBP here. 75 00:05:35,110 --> 00:05:42,280 We have declared a complete we have written a complete program which is used to add two numbers, but 76 00:05:42,280 --> 00:05:43,240 using function. 77 00:05:44,310 --> 00:05:52,230 So here you can see a preprocessor Dorothy Namespaces declared out here, then we can see the next statement 78 00:05:52,230 --> 00:06:00,120 is functioning prototype, and it will be just giving an introduction to compiler that there will be 79 00:06:00,120 --> 00:06:01,620 a functional definition ahead. 80 00:06:01,980 --> 00:06:08,910 And the final senator turntable will be in the final version, namely, the addition and the final change 81 00:06:08,910 --> 00:06:11,900 variable is which accept will be A and B. 82 00:06:12,720 --> 00:06:16,620 So this is just an order we know yet again. 83 00:06:16,630 --> 00:06:27,550 See, we have to mostly like re-edit and addition variable created to store the value add and then a 84 00:06:27,660 --> 00:06:29,040 reading two numbers. 85 00:06:29,340 --> 00:06:30,690 Number one and number two. 86 00:06:31,230 --> 00:06:34,890 Then I'm calling the function to add this number one and number two. 87 00:06:35,490 --> 00:06:40,860 So what happened at equal edition number one and number two? 88 00:06:40,860 --> 00:06:43,950 Then straightaway, the control will be going to here. 89 00:06:44,280 --> 00:06:51,360 That means the function definition here, what you can see in the addition it will accept and the NBA 90 00:06:51,360 --> 00:06:54,660 in the sense, the number one which we have provided will be here. 91 00:06:54,900 --> 00:07:03,060 And number two will be b OK and it will return a plus b, whatever number I have given us, number one 92 00:07:03,060 --> 00:07:05,510 and number two will be stored on standby B. 93 00:07:05,520 --> 00:07:10,320 And if then add these two numbers and B and return that value to that column. 94 00:07:10,320 --> 00:07:14,520 This is that calling function for a function call place, he added. 95 00:07:14,850 --> 00:07:21,990 In return, the value of fatty and it will store the value to this medium now just on the next statement 96 00:07:22,230 --> 00:07:24,330 and pending the addition value. 97 00:07:25,490 --> 00:07:33,500 See, this function is created just after the main function is closed, so you can either create a function 98 00:07:33,510 --> 00:07:38,570 inside the main function itself or you can create it outside, but that's fine. 99 00:07:38,750 --> 00:07:45,710 So if we are, that's why we are providing you function prototype power here, which means the program 100 00:07:45,710 --> 00:07:47,660 doesn't end after the main function. 101 00:07:47,960 --> 00:07:52,190 There are some functions also defined outside the main function. 102 00:07:52,340 --> 00:07:56,900 So now let's see this program in action so that you will understand this problem. 103 00:07:57,410 --> 00:08:02,630 So let me switch to my desktop directly. 104 00:08:03,500 --> 00:08:11,960 Now I'm going to do C++ compiler this program function doc CPB. 105 00:08:13,070 --> 00:08:17,930 Successfully done by now, I am going to get the output. 106 00:08:19,340 --> 00:08:21,680 So it's asking me for the first number I'm giving. 107 00:08:21,770 --> 00:08:25,520 Well, it's asking me for the second number I'm giving. 108 00:08:25,520 --> 00:08:26,870 I gain. 109 00:08:28,630 --> 00:08:29,310 18. 110 00:08:29,770 --> 00:08:31,180 So it will be 30, right? 111 00:08:31,630 --> 00:08:33,750 Let's end up right. 112 00:08:34,090 --> 00:08:40,750 Irishness 30, what happened and first number, he here to execute that no one is 30. 113 00:08:40,960 --> 00:08:41,640 Sorry, Brad. 114 00:08:41,860 --> 00:08:43,630 And number two, he's 18. 115 00:08:43,840 --> 00:08:45,160 So I'm passing this tour. 116 00:08:45,160 --> 00:08:51,610 I am going to show leg and add these numbers and return them to here. 117 00:08:51,880 --> 00:08:53,090 And I'm bringing this back. 118 00:08:53,230 --> 00:08:54,230 That is 30. 119 00:08:54,310 --> 00:08:54,910 That's it. 120 00:08:56,380 --> 00:08:58,540 Hope you have understood this concept. 121 00:08:59,050 --> 00:09:01,860 Now we can jump back to our presentation. 122 00:09:02,170 --> 00:09:03,820 Bed, we have something more to let.