Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
Add to Playlist
Report
Learn Programming Technique C to Master Skills - If .... else if Statement Program
Tutorials Arena
Follow
10/8/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone. This is Sandeep. In my previous video, I have explained about two-way selection
00:12
and I have explained the program in a flowchart. So this was the program that if the purchasing
00:18
amount is greater than equals to 10,000, then 10% discount. If the purchasing amount is
00:24
greater than equals to 5,000, the customer is going to get 5% discount. If the purchasing
00:30
amount is less than 5,000, then no discount. But this time we have to take decision for
00:36
the two times. Okay. And then we have to calculate the discount and the net amount in which the
00:43
customer purchased the goods. Okay. So I have explained the flowchart, this program, and
00:51
now I'm going to implement NC. Let me open the code blocks and a new file. I'm going
01:02
to make the program. I will save it. Okay. Now I will write what hash include, stdio.h.
01:27
I will use what int main and inside it I use what float, p for the purchase, t for
01:36
the discount, and n, the amount in which the customer purchased the goods. I will use a
01:44
message here that what I am going to do is to input the purchase of goods. Okay. So I've
01:56
given a message here and I will use a scanf. So what percent f for the type specifier,
02:08
comma, and p. So the value is going to store inside p for the purchase. Now according to
02:17
the question, if purchase, purchasing amount is greater than equals to 10,000. Okay. So
02:25
according to the question, the discount will be d equals to p into 10 upon 100. Okay. So
02:33
discount is going to calculate and to calculate the net amount, I will write down n equals to
02:40
p minus d. Okay. So I've calculated the discount and the net amount. After that,
02:48
printf slash n, discount is percent d and it is inside where d. Okay. I have to use the
03:02
specifier percent f. I will use what percent f and it's going to display. Okay. So I will
03:17
use the semicolon at the end and what printf slash n, net amount is, that is what percent f,
03:30
then comma, dot n and what semicolon. Now if the condition will get false, I will come to
03:45
what else part. Again, the condition is going to check else if, what p greater than equals to what
03:53
5,000. Okay. If the purchasing amount is greater than equals to 5,000, in that case, as the
04:01
question says, let us see that if the purchasing amount is greater than equals to 5,000 and how
04:10
much? 5%. So the purchasing amount is between 5,000 and 10,000. Okay. So in that case,
04:18
d equals to p into 5 upon 100 and to calculate the net amount, n equals to p minus d. Okay.
04:32
And then again, I will print the, first of all, what the discount. Discount is percent f. Where
04:44
it is? It is inside the d. Okay. And then what printf slash n, net amount is percent f. Where
05:00
it is? It is inside n. Okay. Now here if also the condition get false, it will come to the else part
05:10
and what? It's going to display what? Simply what? No discount. Okay. So I hope I have done
05:24
everything right. I should write down what? Return zero, the exit status. Okay. Of the program. Now
05:36
let us quickly see if there's any error or not in the program. No, I think everything is fine. Let
05:48
me click on the build button. Okay. It's showing me that it's zero error and zero warning and now
05:57
I'm going to run the program. When I run the program, it's asking me the purchasing amount.
06:03
Suppose I input what? 50,000. Okay. So it calculated 10% discount and the net amount is what? 45,000.
06:14
Okay. Let us run one more time. Now this time I'm going to input what? 8,000, the purchase of the
06:24
customer. So it's calculated the 5% and the net amount in which the customer purchased, that is
06:31
7,600. Okay. Then I again run the program and I input what only? Suppose 1,000, in that case what?
06:44
No discount. So everything is fine. There is no error. So let us understand. Suppose I input here
06:54
what? 50,000. It will take the decision here, 50,000 greater than 10,000. Condition is true.
07:02
So this part is going to work. Okay. It's going to calculate 10% discount and then the net amount
07:10
which is going to store inside n and then it's going to display. If I again run the program and
07:17
suppose inside p, I input 8,000. So 8,000 greater than 10,000, the condition is false. It's going to
07:26
come here to the else part. Okay. Again the statement 8,000 greater than 5,000. Yes,
07:33
condition is true. And according to the question, it's going to calculate what? 5%. And I'm going
07:40
to display the discount and the net amount. If I again run the program and suppose I input the
07:49
purchase amount of customer 1,000. 1,000 greater than 10,000, here the condition gets false. It
07:56
will come to the else part. 1,000 greater than 5,000, here also the condition will get false.
08:04
For the second if, the else is here at the down. Okay. So it will come to this else part and going
08:13
to display what? No discount. Okay. So we have seen all the conditions. Now in the next video,
08:22
I'm going to start multiple selection or maybe something else. Thanks for today.
Recommended
7:56
|
Up next
Learn Programming Technique C to Master Skills - Nested If Statement Program
Tutorials Arena
10/12/2024
12:06
Learn Programming Technique C to Master Skills - Continuous If Statement Program
Tutorials Arena
10/8/2024
4:39
Learn Programming Technique C to Master Skills - If... else if Statement Program (Flowchart)
Tutorials Arena
10/8/2024
10:56
Learn Programming Technique C to Master Skills - Loop With If Statement Program
Tutorials Arena
10/13/2024
4:57
Learn Programming Technique C to Master Skills - Loop with If Statement Second Program Continue...
Tutorials Arena
10/17/2024
5:14
Learn Programming Technique C to Master Skills - Single If Statement Program Explanation
Tutorials Arena
10/12/2024
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second Program
Tutorials Arena
10/17/2024
2:58
Learn Programming Technique C to Master Skills - Nested If Statement Program (Flow Chart)
Tutorials Arena
10/12/2024
3:28
Learn Programming Technique C to Master Skills - Switch Case Program ( Continue ...)
Tutorials Arena
10/19/2024
4:57
Learn Programming Technique C to Master Skills - Loop With If Statement Program ( Flow Chart )
Tutorials Arena
10/13/2024
4:54
Learn Programming Technique C to Master Skills - Single If Statement Program (Flow Chart)
Tutorials Arena
10/12/2024
5:29
Learn Programming Technique C to Master Skills - Continuous If Program (Flow Chart)
Tutorials Arena
10/8/2024
3:21
Learn Programming Technique C to Master Skills - Third Program - Call by Reference (continue...)
Tutorials Arena
11/8/2024
12:25
Learn Programming Technique C to Master Skills - Call By Reference Program
Tutorials Arena
11/8/2024
3:37
Learn Programming Technique C to Master Skills - Pointers And Arrays Program ( Continue...)
Tutorials Arena
11/9/2024
9:20
Learn Programming Technique C to Master Skills - Union Program
Tutorials Arena
11/10/2024
4:22
Learn Programming Technique C to Master Skills - Pointer And Arrays Program
Tutorials Arena
11/9/2024
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
10/17/2024
3:16
Learn Programming Technique C to MasterĀ Skills - First Program of Function ( Continue ...)
Tutorials Arena
11/3/2024
9:09
Learn Programming Technique C to Master Skills - Second Program( Call by Reference)
Tutorials Arena
11/8/2024
8:01
Learn Programming Technique C to Master Skills - Loop Within Loop Program
Tutorials Arena
10/17/2024
9:12
Learn Programming Technique C to Master Skills - Program of Recursion
Tutorials Arena
11/6/2024
10:48
Learn Programming Technique C to Master Skills - Structure and Functions Program
Tutorials Arena
11/10/2024
6:52
Learn Programming Technique C to Master Skills - Fourth Program - (Call by Reference - continue..)
Tutorials Arena
11/8/2024
5:36
Learn Programming Technique C to Master Skills - Switch Case Program ( Use of Integer Value)
Tutorials Arena
10/19/2024