Learn Programming Technique C to Master Skills - If... else if Statement Program (Flowchart)

  • last week
Transcript
00:00Hello, everyone. This is Sandeep. In the last video, I explained one-way selection program.
00:09I'm going to explain program of two-way selection, almost the same program. Only the thing is
00:16that here I have to take what two times decision. So the program is what a shopkeeper gives
00:22a discount to its customer on their purchase. If the purchasing amount of the customer is
00:29greater than or equals to 10,000, then it's going to get 10% commission. But if the purchasing
00:36amount of the customer is greater than or equals to 5,000, then the customer is going
00:41to get 5%. And if the purchasing amount is less than 5,000, then customer is not going
00:49to get any discount. So if the purchasing amount is greater than or equals to 10,000,
00:55then 10% discount. If the purchasing amount is greater than or equals to 5,000, that
01:00means the purchasing amount is between 5,000 and 10,000. The amount is between 5,000 and
01:0710,000. Then the customer is going to get 5% discount. And if the purchasing amount
01:13is less than 5,000, then no discount. Okay? So I've taken the three variables, P for purchasing
01:21amount, D for discount, and for the amount, I'm going to input the purchasing amount
01:29in P. If the condition here is true, that is greater than or equals to 10,000 and 10%
01:34is going to calculate. If the condition falls here, so it will come to the no part. And
01:42if the purchasing amount is between 5,000 and 10,000, according to the question, it's
01:47going to be at 5%. That is going to calculate. That amount is going to calculate and then
01:52display. And if here both the condition that falls, in that case that it only display what
01:59no discount and then stop. So let us do the dry run. Suppose I input the purchasing amount
02:05of the customer that is what 50,000. It will come to the if statement. If 50,000 as inside
02:14P, it is 50,000. 50,000 greater than 10,000. Yes, 50,000 is greater than 10,000. 10% is
02:22going to calculate and the resulted value is going to store inside D. Okay? Then from
02:29the actual purchasing amount, the discount is going to deduct and the net amount in which
02:36the customer purchase the goods, which is there inside N, it's going to store. Then
02:41I have used the print statement to print the discount in the net amount and stop. Okay?
02:49So as the formula here applied, so discount will be calculated over 5,000 and it's going
02:56to deduct that is 50,000 minus 5,000 that is 45,000 and both the things are going to display.
03:04Okay? Now again I'm going to run. Now this time the customer having the purchasing
03:12amount what is that is 8,000. So another purchase, another customer have made the purchase
03:18of 8,000. Okay? So it will come here if 8,000 greater than 10,000. Here the condition is false.
03:25It will come to the no part. If 8,000 greater than 5,000. Yes, the condition is true. According
03:32to the question, 5% is going to calculate. So it will calculate. The resulted value is going to
03:37store inside D that is what 400. Then the net amount is going to calculate that is 7,600 that
03:49is 800 minus 400. So 7,600 that is the amount in which customer purchase the goods and then
03:56it's going to display. Okay? Now let us understand with the amount of another customer that is
04:074,000. If purchasing amount is of another customer is 4,000. So if 4,000 greater than 10,000 here
04:15the condition is false. It will come to the no part. If 4,000 greater than 5,000 here also
04:21condition is false. It will come to the no part and going to display with no discount and then
04:27stop. So very easy. I hope you understand in the flowchart. In the next video, I will make the
04:33same program in C. Thanks.

Recommended