WEBVTT

00:00.510 --> 00:07.890
We went over some simple functions last time but today was talk about giving functions arguments or

00:07.890 --> 00:09.390
parameters.

00:09.780 --> 00:17.870
I said that the parentheses in the function signature can hold variables that we can pass values into.

00:18.330 --> 00:21.010
So let's see how we could do that.

00:21.060 --> 00:34.670
So let's say we had a function call it value and give it a an argument in X or parameter index.

00:34.680 --> 00:38.250
So it's really just like declaring a variable.

00:38.320 --> 00:47.620
So X can be used in the print value function to do any calculations that print value needs to do.

00:48.030 --> 01:00.580
And if you remember the scope lecture X is the PSK the scope of index is really just the the scope of

01:00.850 --> 01:03.130
the print value function in general.

01:03.130 --> 01:08.690
So you can only use X in the print value function.

01:12.570 --> 01:20.230
So let's just say see each integer.

01:20.460 --> 01:35.600
It's X and know that and let's call the Felty function.

01:36.470 --> 01:38.680
And we just need to give it an integer.

01:38.720 --> 01:50.780
So this B since x is also part of the signature of the function the caller must provide a value to pass

01:50.780 --> 01:51.670
into it.

01:51.770 --> 01:54.680
So that's what we're doing in in here.

01:58.740 --> 02:01.720
So you see what happens.

02:03.180 --> 02:07.830
So not surprisingly it just says the integer is five.

02:08.010 --> 02:13.440
Now it doesn't we don't have to just give it literal values like 5 you could have like variables say

02:13.470 --> 02:29.890
10 Zad is to 10 and say you said hey and print out 10 can also have say arithmetic operations so say

02:29.970 --> 02:32.410
Zad plus 20.

02:32.670 --> 02:40.530
It should print out 30 right because it'll actually do the math the evaluation of the addition here

02:41.040 --> 02:50.980
and then pass to the print value function and then print out the result.

02:51.160 --> 02:57.960
So it doesn't all have to be just one argument you could have multiple arguments.

02:58.000 --> 03:04.790
So how to do that is we have a comma between all of our arguments.

03:04.800 --> 03:16.090
You can have char c that floats while say and we have to update our function signature down here as

03:16.090 --> 03:18.440
well in that definition.

03:18.610 --> 03:21.060
See why

03:24.460 --> 03:29.010
if we call this now we have to call it with all three of those values.

03:31.250 --> 03:42.750
And say and or is here to say out

03:46.510 --> 03:54.280
character is C an inch

03:57.360 --> 04:00.220
float is

04:03.100 --> 04:06.390
y.

04:06.590 --> 04:16.300
And that's C all three values that we put into print value are being outputted.

04:16.400 --> 04:24.970
So that's how you can have multiple parameters in a in a function.

04:27.010 --> 04:36.070
So we'll be talking about crammer's in arguments bit more a bit later in a different section but we

04:36.070 --> 04:39.080
don't have tools to talk about it quite yet.

04:39.100 --> 04:45.010
So we need to actually go over those tools and we'll do that in a bit of a later section and I'll show

04:45.010 --> 04:48.010
you some more interesting things they can do.

04:48.100 --> 04:52.840
RAMmers So in the next lecture we're in talk about return about this.
