Category
š
LearningTranscript
00:00Hello everyone. In the last video, I explained about one-way selection. I explained this
00:10program in the flowchart that a shopkeeper gives discount to its customer on their purchase.
00:19I explained this program with the help of the flowchart. Now I'm going to implement
00:25the same program in C. So let me open the code blocks and inside it, I'm going to make
00:37the program. We'll save the file. Let us give a name to it, new3. Okay. It should show in
00:50the save as type what C and C++ file and we'll save it and where it's going to save inside the
00:56C programs folder. Okay, this is the location. I'm going to first of all include the header file
01:06stdir.h. Each syntax which I'm using has include stdir.h main function. I'm going to explain.
01:18I'm going to take what float data type and I will take the two variables p for principal,
01:25d for discount and n for the amount in which the customer is going to purchase the goods.
01:32Okay, and I will use here a message that is what input to purchase of customer. Okay,
01:45like this. Then I'm going to use the scanf and inside it, I will use what type is specifier
01:54%f and then the purchase is going to store inside p. Okay, now the condition if p greater
02:07than equals to what 10,000. If so, then I have to calculate 10% discount. So d equals to p into
02:1610 upon 100. Okay, so the resulted value that is the discount is going to store inside d. Now
02:25what I have to do, I have to calculate the amount for that n equals to p minus d. The
02:32actual purchase minus the discount will get the net amount in which customer purchase the goods.
02:38I will display both the things. Let us discard first of all the discount, discount is %f where
02:56it is, it is inside d. Okay, and then what printf slash n, net amount that is the amount in which
03:10the customer purchased the goods, %f that is inside what n, comma n. Okay, now if the condition
03:23will get false, so it will come to the else part and inside it what printf slash n, no discount.
03:33Okay, and then what semicolon. At the last here, I will use what return zero. Okay, so I hope
03:44everything is okay. Let me click on first of all on the build button. Okay, it's showing me zero
03:52and zero warning. Let me run the program. When I run it, it's asking me to input the
03:58purchasing amount. When I input what 25,000, so it's showing me what 2,500 and then the amount
04:07is what 22,500. Okay, when I again click on build and run, then I'm going to input the purchasing
04:19amount of the second customer. Suppose I will put 500, so what should display, no discount. Okay,
04:28so when the purchasing amount which is there inside the p is greater than 10,000, then this
04:37particular block, this particular portion is going to work, going to calculate the discount and the
04:44amount in which customer purchase the goods. But if I input purchasing amount less than 10,000,
04:53so here the condition will get false and for false, here it is what else part. So it's going to come
05:00to the else part and then going to display what no discount. Okay, I hope you understand. In the
05:08next video, we'll see some more programs. Thanks.