Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
More
Add to Playlist
Report
Learn Programming Technique C to Master Skills - Single If Statement Program Explanation
Tutorials Arena
Follow
11 months ago
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone. In the last video, I explained about one-way selection. I explained this
00:10
program in the flowchart that a shopkeeper gives discount to its customer on their purchase.
00:19
I explained this program with the help of the flowchart. Now I'm going to implement
00:25
the same program in C. So let me open the code blocks and inside it, I'm going to make
00:37
the program. We'll save the file. Let us give a name to it, new3. Okay. It should show in
00:50
the save as type what C and C++ file and we'll save it and where it's going to save inside the
00:56
C programs folder. Okay, this is the location. I'm going to first of all include the header file
01:06
stdir.h. Each syntax which I'm using has include stdir.h main function. I'm going to explain.
01:18
I'm going to take what float data type and I will take the two variables p for principal,
01:25
d for discount and n for the amount in which the customer is going to purchase the goods.
01:32
Okay, and I will use here a message that is what input to purchase of customer. Okay,
01:45
like 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:07
than equals to what 10,000. If so, then I have to calculate 10% discount. So d equals to p into
02:16
10 upon 100. Okay, so the resulted value that is the discount is going to store inside d. Now
02:25
what I have to do, I have to calculate the amount for that n equals to p minus d. The
02:32
actual purchase minus the discount will get the net amount in which customer purchase the goods.
02:38
I will display both the things. Let us discard first of all the discount, discount is %f where
02:56
it is, it is inside d. Okay, and then what printf slash n, net amount that is the amount in which
03:10
the customer purchased the goods, %f that is inside what n, comma n. Okay, now if the condition
03:23
will get false, so it will come to the else part and inside it what printf slash n, no discount.
03:33
Okay, and then what semicolon. At the last here, I will use what return zero. Okay, so I hope
03:44
everything is okay. Let me click on first of all on the build button. Okay, it's showing me zero
03:52
and zero warning. Let me run the program. When I run it, it's asking me to input the
03:58
purchasing amount. When I input what 25,000, so it's showing me what 2,500 and then the amount
04:07
is what 22,500. Okay, when I again click on build and run, then I'm going to input the purchasing
04:19
amount of the second customer. Suppose I will put 500, so what should display, no discount. Okay,
04:28
so when the purchasing amount which is there inside the p is greater than 10,000, then this
04:37
particular block, this particular portion is going to work, going to calculate the discount and the
04:44
amount in which customer purchase the goods. But if I input purchasing amount less than 10,000,
04:53
so here the condition will get false and for false, here it is what else part. So it's going to come
05:00
to the else part and then going to display what no discount. Okay, I hope you understand. In the
05:08
next video, we'll see some more programs. Thanks.
Be the first to comment
Add your comment
Recommended
7:56
|
Up next
Learn Programming Technique C to Master Skills - Nested If Statement Program
Tutorials Arena
11 months ago
12:06
Learn Programming Technique C to Master Skills - Continuous If Statement Program
Tutorials Arena
1 year ago
10:56
Learn Programming Technique C to Master Skills - Loop With If Statement Program
Tutorials Arena
11 months ago
4:54
Learn Programming Technique C to Master Skills - Single If Statement Program (Flow Chart)
Tutorials Arena
11 months ago
12:25
Learn Programming Technique C to Master Skills - Call By Reference Program
Tutorials Arena
11 months ago
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second Program
Tutorials Arena
11 months ago
8:32
Learn Programming Technique C to Master Skills - If .... else if Statement Program
Tutorials Arena
1 year ago
9:20
Learn Programming Technique C to Master Skills - Union Program
Tutorials Arena
10 months ago
4:14
Learn Programming Technique C to Master Skills - Explanation of Second Program
Tutorials Arena
1 year ago
9:12
Learn Programming Technique C to Master Skills - Program of Recursion
Tutorials Arena
11 months ago
2:58
Learn Programming Technique C to Master Skills - Nested If Statement Program (Flow Chart)
Tutorials Arena
11 months ago
6:40
Learn Programming Technique C to Master Skills - Explanation of Array
Tutorials Arena
11 months ago
4:57
Learn Programming Technique C to Master Skills - Loop With If Statement Program ( Flow Chart )
Tutorials Arena
11 months ago
2:41
Learn Programming Technique C to Master Skills - Explanation of First Program of C Language in Flowchart
Tutorials Arena
1 year ago
8:08
Learn Programming Technique C to MasterĀ Skills - First Program of Function
Tutorials Arena
11 months ago
7:20
Learn Programming Technique C to Master Skills - Explanation of First Program of C Language in Code - Blocks
Tutorials Arena
1 year ago
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
11 months ago
4:22
Learn Programming Technique C to Master Skills - Pointer And Arrays Program
Tutorials Arena
11 months ago
12:03
Learn Programming Technique C to Master Skills - Array of Structure Program
Tutorials Arena
10 months ago
3:40
Learn Programming Technique C to Master Skills - Array of Pointer Program
Tutorials Arena
11 months ago
8:45
Learn Programming Technique C to Master Skills - Explanation of Pointer - I
Tutorials Arena
11 months ago
4:55
Learn Programming Technique C to Master Skills - Linked List Program
Tutorials Arena
10 months ago
10:48
Learn Programming Technique C to Master Skills - Structure and Functions Program
Tutorials Arena
10 months ago
8:01
Learn Programming Technique C to Master Skills - Loop Within Loop Program
Tutorials Arena
11 months ago
13:04
Learn Programming Technique C to Master Skills - Double Dimension Array Program
Tutorials Arena
11 months ago
Be the first to comment