Hi guys.
Welcome back.
Actually before jumping into the stadium simulator program we will discuss a bold statement.
Because this is one of the important concept which we're going to use in the program.
OK.
So first of all what did the switch statement.
OK.
It's his statement as the value of a variable case match matches found a block of statements associated
with that particular case is executed.
OK.
So this is the basic syntax for a statement.
OK.
So later we'll discuss there with the help of the program.
So what happens here is this expression value will be evaluated in each case.
OK.
For example if this value is to OK so a to match with each case here it will match actually.
Here it is 1.
But our values too.
So this this block of code will not be executed.
Then again.
OK.
This is true and our expressions of two.
OK.
For example then this particular this block of statements will be executed.
And then this way with the help of this big statement which will come out of this look at you the next
the sequence of statements will not be zero direction.
OK.
So this how the case such case works actually and one more thing for example like I'm ex I'm going in
a value called a fight and they try to check with each case really like one two three or four whatever
it is in guess the final is not available then what to do is like after checking all the case values
it will if it is if that particular case that particular expression is not available then the default
block of statements will be executed.
So now we will see a small program to understand more about this hour program we using as your statement.
So here what I'm doing here is I have a variable within digit error type and we have internalized the
x variable with the true value.
Okay so this is a such case which we have discussed in the right which we had discussed earlier.
So switch than the expression then they'll be different cases and they'll be default blockers.
Okay.
So here if you see here I'm just going to parse the value of street so which means by right this block
of statements would be printed and with help of breakage will come onto this look.
OK.
So in case if we're not not able to find any of the match.
OK then the blur.
The default bulk of statements will be executed.
So here what happens is this index is three.
This particular statement will be executed and it will come out of this program so the next block off
a quarter not because go down to the next statement will not be executed.
Once this match this match was found.
OK so we'll exclude this program and see what happens x values 3 and it is trying to do it this value
is getting past year to the switch statement and it is trying to match with each case.
So case in this case one of the three is not equal to 0 1.
So this will not be excluded again.
Case two so two is not equal to three so this will not be executed.
So cases is matching with three.
So this particular book of statements will be has been executed.
And what we can do is we will try to change the value but what is not available here.
So if if it's not matching with any of the case then the default block of statements has to be executed
a case one not matching gets two not matching guess not matching on the default block of statements
has been executed which you is no not match with any case.
So this how the case works actually.
So now we will jump to the atom search program and see.
Hi guys.
Welcome back.
In the early edition we have seen about which case we have seen all the same bags and we already discussed
the above statement using a small such program.
And now here we are going to right the atrium simulated using a such case.
OK so the logic we already goes to the project logic we are discussed in the reality lesson.
So we are we can see we will see now how we can include those logic in the same program in the C program.
OK.
So here what I'm doing is this as usual these are after five since I'm going to I mean they'll be to
function in the main function.
The second is that the second one is it in transition.
There is one more using the different function which I'm going to use here and here these are the variables
I have declared with the indigenous type.
You may have a cushion.
How come like every time we include these variables inside the main function or inside is a different
function.
But here if you see I have declared abo main function.
Okay.
So please note A few are declaring any variable abo main function.
Okay.
These are called as a global variable.
Okay.
Which means this global variable can be used in any of these any of the same functions.
Which is which are available in this program.
Okay.
So for example there are 10 functions.
Again this variable can be used in all different functions.
Okay.
So that's when this code is called as a global variable you No need to declare in each and every function
separately.
So C is offering an option called global variable very few if you're declaring about the main function.
And this particular variable can be used in any of the functions below.
Okay.
So these are the this variable I have declared the time digit and it happened I have one more variable
with double digit type I now in the values thousand.
Okay.
This well the first thing what happens is like we'll get a come on.
So here also I'm doing the same thing.
And when we execute this program the stadium simulator using C program it will from the usual display
this will come to x rays at bank then it'll do it from for the pin which we discussed earlier.
The first thing is it will it will perform for the pin.
So here I am just for this purpose I am just giving the values one two three four.
So if the pin is one two three four.
If the pin is one two three four.
Then this code will be executed.
And this will be executed.
Okay here.
Does not equal to.
Which means you spin value and capturing the value here and the runtime.
And if this is not equal to one two three four.
Which means it will try to compare with this one if it is is not equal not this is not.
This is not equal to one two three four.
Then this this message will be printed which means sorry your opinion is wrong please take into the
car.
Okay you've got it.
I mean if this is true then this particular function will be called this instead will be executed again
debating if bin is not equal to this one then means it is false so which means this particular statement
will be executed.
This will be printer to the customer but if this is correct then the else block will be executed enrichment
in which it recalled it in transaction function.
OK so what's happening in this A.T.M. transaction function.
OK so we discussed as we discussed earlier
this is what we had discussed earlier right.
We had like the opinion correct then this particular option should be displayed.
OK so that's what we do.
That's what we are doing here actually.
So if the bin is correct if if the bin is wrong this is a blueprint of this current this function will
be executed this function will be called and in this function what happens is when even this function
is getting called it all it will print in the sequence zone just four options actually.
So what what operations what particular task the customer wanted or what particular transaction what
the customer wanted or for example where there is a balance and carry a cash with their own deposit
cash or he want to exit from the program.
Okay so this four options when be prompted to the customer for example.
Okay.
This for particular options have a the logic in four different cases.
Okay.
That say in one such case in what Newman switched it meant I have written four cases or the case one
is for the balance and Cody gets to his for the cash withdrawn guest 3 is for the deposit and case for
or before statement.
I put it as like thank you for using it themselves.
You may meet meaning they've when the customer pressed the 4th option and tried to match with each case
and there is no fourth case.
So that's where the default it'll will come to the default case and it will end the block of statement.
Okay so this how is this how I have designed it actually.
So what we will try to go line by line for each case.
Okay so what we have discussed earlier here is like for example if the customer selected option as one
we need to display the balance.
Okay.
So here prompt to the customer your I mean guess when the customer messaged one I mean a in one to ensure
the balance like this balance can guess at this thousand.
Okay.
It is just printing.
Here is the balance.
Okay.
I mean have insulins this thousand.
Okay so now.
So after this.
What will happen is like till the customer needs to proceed.
Right.
So I have written one more printed statement here.
So.
Press 1 to proceed as to to exit okay so press if the customer press 1 it means they're gonna call the
ATM transaction function.
Okay.
So for example like if the customer has to say to come out of the car it'll come out of the store.
Okay.
So for example if you want to continue with another option that cash you draw a deposit.
So I'm giving an option to the customer.
Like whether I mean you can press 1 or 2 you know in order to proceed further okay.
For example the customer plus 1 then I'm putting on my if condition here if this transaction a transaction
is equal to 1.
Then again you'll call the transaction function.
Okay so if it calls again then again the four options will be displayed at the customer.
Okay.
So for example in the in the in the second row then he free press 2.
Okay.
So again it will try to match with each case.
Case when is not mentioned this will not be as good as we will come to case 2 which is the withdrawal.
Okay.
So in withdrawal what we discussed earlier is we need to plan for the amount actually.
How much and what do you want to control.
So it will prompt for the that it for the amount to withdraw so we need we capturing this value with
the help of scan function and what I'm doing here is like if I'm comparing this amount know with the
balance.
Okay so balance is thousand.
Okay.
I have a thousand balances those quarter thousand.
Okay so if the amount the request is 500 or if it is less than balance amount then will print dismiss
it.
For example if the customer key gate in the Montez finder the dollar.
Okay so it will be captured in this variable and I'm comparing this value of a debt actually balance
balances thousand which means the customer can withdraw until nine hundred ninety nine dollars actually.
Okay so until thousand dollars sorry under those dollars you can withdraw.
Okay.
So I put aside less than or equal to balance.
Okay so for example if it is a thousand eight or nine hundred it will try to see see whether this is
less or equal to this balance amount.
Then we will print the messages please collect your cash.
Then what we do is that that particular amount or whatever he keyed in that will be subtracted with
the actual balance and it will be captured the balance variable and we are displaying to the customer
that this is the available balance which you have after the building the amount.
Okay.
So after withdrawal is the balance amount which you have in this eye contact with respect to the customer.
Okay.
So often then it again will prompt this a message to the customer whether you want to proceed or not
if you want to proceed for the freedom of the customer precedence one.
Again to say it can't function will be acquired.
And again these four options will be discrete to the customer.
Now if we select three option then it will come to this particular deposit case.
Okay then this block of case will be executed.
Okay.
So then when he wanted deposit and wanted to run for this I want to say that it will prompt for this
message.
PRESENTER I want to be positive then will we are capturing that particular moment with an office can
function.
So what I want.
We have captured that particular variable amount will be added to the balance.
Okay.
So the balances for example thousand.
OK.
Those in place for example like if we want to deposit our own defined dollars for example.
OK.
So that will be added with the actual balance then the this variable content the full balance and deliberately
spread to the customer.
This is the new balance after depositing the amount.
OK.
So again it will prompt to the user whether you want to continue or not.
If we have already seen all the three functions at three more.
That's right.
We have seen a withdrawal.
We have seen the deposit.
We have seen the balance in cutting.
So after that like the ones the customer press 2 it will come out of this look.
OK.
So.
So this how it works actually.
Again I am repeating this program.
So I have a function prototype he does it in a different way which would exclusively function prototype.
We we are we are informing the compiler that the definition will come down the line this program.
These are the global variables which you are going to use in the main function as a function of the
global variable under which you have said I want s thousand dollars like this is the available balance
which the customer can customize having no.
Okay so as usual the program will execute from the main function.
So this will be prompted to the customer and when we execute this program it will tell will come to
this bank and a class with it being first is sprinkling in is incorrect.
Then this message will prompt prompter is the pin is wrong then this particular message you labor intensive
the business credit is a dim transaction function will be correct.
Okay so in this what we are going to do is we are going to show forward particular options to the customer.
Okay.
For Adoption balancing 30 cash withdrawal deposit cash and the floater will be exit when the customer
pays for it will exit from this program.
Okay.
So on this particular each particular options each particular options I have written the logic in different
each case actually using the system.
Okay just admin we are discussing okay this is a statement.
So there'll be three cases here one case is for the balance and goodie.
Okay.
The second case is for the cash withdrawal and the third case will be for the deposit.
Okay.
For example of the customer message that's one which means that it'll it'll tie this particular variable
will capture the value from the customer and do what I do a search type to match with each case he had
one missed this is matching so this block of code will be executed in which what happens is like it
will from this message like this is available balance several balance we set a thousand so thousand
will be shown and thus he concept of the customer.
Okay then it last for the day then it'll be on motor a message will prompt the customer in order to
continue for days for the customer press 1 then I have one more logic here.
And then again call the it transaction function if destroyed and it'll come out of this loop.
Okay so if that if if for example like if you press 1 then this will be executed.
Again default option will be shown to the customer.
Suppose you fee if you press.
Then again do the research get you tried to match with each case then dispatch.
His is matched then this block of judgment will be executed.
Again to last for the amount how much more do you want to withdraw that amount.
You will literally capture the this can function and work combating that amount with that thousand dollars.
And if the withdrawal of she was keen but the customer is less than the available balance then.
And then we should print we will print a message card please correct your cash then that particular
amount that particular amount will be separated from the actual balance and that the remaining balance
will be shown to the customer.
Okay so again I'm asking the customer that whether you want to continue or accept.
So if the customer plus one then again these four options will be spread to the customer.
Now if he does three then it will come to the case three because he's matching with Cassidy then it
will prompt this message to the customer how much and what do you want to deposit then it'll be added
with the actual balance.
And actually the final balance will be shortened the customer does the new balance after adding the
deposited amount.
Okay.
So after that when they've been the customer press 1 again here.
Then again the the this particular options will be shown if the customer plus to it will exit from this
program.
Okay.
So it gives the customer plus four or five whatever it is then it right to match with case 3 case to
case 1.
So it will not match or the default block of shipment will be executed.
It's prompting this message.
Welcome.
Let's face it.
Bank as it prompted their EDI mission and a near dimensional details for the Europeans to hear auto
rate simulator it's asking for the pin now.
So here I validating with one two three four.
So I'm going in the correct PIN 1 two three four C so it validated this validation successfully now.
So that's why I like this particular function it's called now.
So okay so since this function is called a despotic adoptions or display to the customer.
So here I what I'm doing is first time I'm keying in the value of one.
So to see the balance C is showing as your balances thousand thousand dollars.
Okay so which means the score was executed correctly.
Okay so here I said that's thousand so it's showing us thousand.
Okay.
We just got it.
So now again do you want to perform other than transact in the transaction and passing is 1 actually.
So it would compare with this and again if you call the item transaction function to see what happens
see again I am at message here is 1.
So it is compared with this variable and since it's good.
Okay.
So I mentioned two here.
So what it does is this product to value will be captured here and they try to match with each case
which means the balance included failed because it's too.
So just do it.
Now I have given the option option called 2 which is cash withdrawal.
So when a getting to it will capture the value here.
That this will pass to the this statement and it is set to match with each case or two is not matching
with this.
So this will not be executed.
Then it will come here then two is matching with this choice.
So this block of code will be executed.
So it's asking for the.
That's why he's asking please and trombone to a drop is our moon a prison term to.
Since my balance is a thousand.
I'm just going in as 500 which I want to withdraw.
So please correct me.
So what is happening is defined as less than or equal to balance with just thousand so condition is
true.
So that's where is prompting this message please collect collecting cash police collect your cash and
it's prompting the available balance which means a lot to a thousand and balances thousand minus amount
of a drug which I mean and we check it only to find that a thousand minus 500 is for the balance and
what is fine that it will be saved in the balance variable and this balance variable is displaying the
value that depend on the balance somewhat.
Which means it is getting printed here.
OK so your available balances balance this particular variable amount which is five hundred.
Okay.
So again it's prompting me a message should you want to perform on the transaction.
Should be.
This is what did this particular statement is getting is good to know.
Again press 1 to proceed further.
Okay so we have completed balancing career we have completed cash withdrawal now I will do deposit cash
I'll get that option.
So if this condition is true this will be executor right so it is gonna be good to note the three again
the transaction options are getting this No I'll press 3 No.
So.
So what happens here is three is getting captured.
So these three values getting passed here and this is trying to match with each case.
So case when is not matched history is not matched.
Case Three is matched because the value which I mentioned is three three is matching with Cassidy.
Okay so that expression is getting matched.
So this particular block of quarterly will is good enough.
So that's why is asking please enter.
I want to deposit this entrapment deposit.
Okay.
So now I want to mention that six 600 for example.
Okay.
Don't find the dollars then I'm depositing 600 dollars.
Okay.
Five hundred plus six hundred thousand hundred just correct.
So that's what we see here.
I want to deposit is extended plus balance is 500.
So that's why.
Let me correct here.
So I'm on to the positives.
600 balances fine.
No so that's why it's a thousand hundred.
OK so that's a showing you showing them as a thanks for depositing your new balances this month.
So thanks for depositing your new balances this one.
OK.
Which means this balance very well have the addition of a month to deposit value plus the available
balance.
Okay I will balance was four handed then the new deposit on Monday with six senators so thousand hundred
is a bonus note.
That's what he did here.
So now hold on.
I tried all the options so I guess I didn't want to continue.
No.
For example like.
Okay I assume that if I want to continue to again request one.
No.
Our best option is for.
Okay.
So I pressed option as for.
No thanks for using it in services.
So this message with Sprint to for because Ford is not available in any of the guests because case when
they get to is the guess is that it guess what I have not mentioned.
So it tried to match with each case it's not my on that.
So the default block of code has been executed.
This is how we can use a true statement in C program.
Also we have discussed dashboard project and also we are developed as a team.
Similarly attached using a C program.
Okay so thanks for watching.
I'll get you guys in the next session by phone.