Category
š
LearningTranscript
00:00Hello friends, in the last video I have explained Continuous IF program in flowchart and the
00:09same program I am going to implement.
00:13Let us see what was the program.
00:14This was the program and the program was that a bank introduced incentive policy of giving
00:23bonus to all its account holders irrespective of their balances.
00:28Balance amount is greater than equals to 10,000 gender is what male in that case 5% balance
00:33greater than equals to 10,000 female in that case 10% and if less than 10,000 the amount
00:41is and whatever the gender either it's male or female then bank is not going to give any
00:49bonus.
00:50So no bonus.
00:51Okay.
00:52So I have explained it in flowchart in my last video.
00:55Today I am going to implement in C. Let us see how first of all include stdio.h okay
01:07and then int main okay so I am going to save it first file then save I will give a name
01:20to it prg.quantif okay now let us think about the variables which I have to take that is
01:34float for total balance tb for the amount a what else I have to take okay and then char
01:46g for the gender okay and here as I have to calculate the bonus also so b for the bonus
01:52okay.
01:53Now what I have to input that I am going to display here enter amount and gender okay
02:10so I have to input the amount and the gender so I will use scanf first of all printf and
02:17then print s okay here I will use what and a and here what and g for the gender okay
02:29now if amount is greater than equals to what 10,000 okay and then I will use the brackets
02:41and again I will take the decision if g equal equals to in a single quote what m okay so
02:51if this both the condition gets true so as the question says what the question says greater
02:58than equals to 10,000 gender is male and 5% calculation okay we are going to calculate 5%
03:06so how that is b equals to a into 5 upon 100 okay so we will get the bonus and then tb equals to a
03:19plus b okay so the total balance now let us display both the things first of all what slash
03:26n bonus is that is percent d sorry percent f and then what comma where it is inside b okay
03:38then what printf total balance is percent f close over noted comma okay and then what comma
04:01and where it is inside tb okay so if the amount is greater than 10,000 and if the gender is male
04:12in that case the 5% is going to calculate the bonus amount will be what 5% otherwise it will
04:20come to the else part again if a greater than equals to 10,000 so this will not be the condition
04:30will check first if suppose here if the grade is equal equal to m and if the condition get false
04:39of what gender that if gender is not equal equal to m okay if this condition get false will come
04:49to the what else part and if gender equal equals to f as for the f for the female okay so this
04:57condition going to check in that case the bonus which the bank is going to give that is 10% okay
05:06on the amount and then total balance equal to a plus b the amount and the bonus okay then we have
05:17to print both the things okay bonus is percent f where it is inside b and then what printf slash n
05:33total balance is percent f okay comma tb now suppose if this condition also get false
05:51here the condition becomes true but here the condition get false so it will come to the else
06:00part of the second if statement but here also this is statement get false okay once it's check
06:08g equal equal to f it gets false it means you have input the wrong grade for this if okay
06:17here we will be having what else part and inside it display what printf slash n wrong grade okay
06:28it's going to end here now this if statement this one okay it's going to this is going to
06:44close here okay so when the first condition the initial condition this one gets false okay for
06:55that if the amount is less than 10,000 in that case what will happen it will come to this part
07:04and what we have to do then if the amount is not greater than 10,000 it's less than 10,000
07:18so simply what we will do in the else of the first statement we have to display that is what printf
07:24that is no bonus okay so the employee is not going to get any bonus okay this is the program
07:39friends and here I should write down for the exit status what return zero okay and save it so let
07:53us click on build so it's zero error let me run it suppose I input for 20,000 okay and grade m
08:05so what it should display it should display the bonus 1,000 so the total balance is what 21,000
08:13okay again if I run it with amount 20,000 and the gender what f for the female in this case
08:27the one is to will calculate 10% that is 2,000 the total balance will be what amount plus bonus
08:3520,000 plus 2,000 or 22,000 okay I will check each and every condition suppose 20,000 and I
08:47have input what k the wrong grade so it should display what wrong grade should notice I should
08:53have written here what wrong gender sorry so what should display wrong gender when I display it
09:03okay when I input 20,000 and what k so wrong gender so it should display what wrong gender
09:10okay and if I again run the program with a small amount that is 500 with m that is male
09:24in that case it's going to display what no bonus okay so I have checked each and every
09:30condition let us see if suppose I haven't put 20,000 and gender m so these two condition get
09:42true okay as the amount is 20,000 the gender is what m for the male these two conditions get true
09:49so this statement is going to work it's going to calculate the bonus and the total balance
09:56now if I run the program one more time this time 20,000 greater than 10,000 suppose I input
10:0220,000 for the amount and for the gender what f so here the condition will get true
10:08but here the condition will get false for the second if okay it will come to the else part
10:14again it's going to check if it's inside g it's f f equal equal to f if the condition is true
10:20so according to the question 10 percent of bonus is going to calculate total amount is going to
10:26calculate and then it's going to display the total amount or you can say the total balance
10:31that is bonus plus amount okay amount of the account holder and the bonus that will be added
10:38and it's going to display what total balance now if you are going to input a wrong rate so what
10:45will happen the first condition is going to true as it's 20,000 greater than 10,000 but you haven't
10:50put a wrong rate that is k so here the conditional get false it will come to the else part here also
10:56the conditional get false so in that case it's going to display what wrong gender okay and if
11:04I input here only what 5,000 and suppose here I input what m for the male so here the conditional
11:13get false here also the conditional get false and both the cases conditional get false
11:18so for this first if which is going to add at the right here at this place
11:27this okay after here the else part is here okay and it will show what no bonus
11:37I hope you understand the concept how to use the if statement okay and
11:49continuously how to apply the if statement and do the calculation work and we'll get the result
11:56this is the program friends I hope you understand
11:58the next video I'm going to explain something else bye