Decision Control Structures:
The control structures help in making decisions when a program is being executed.
if Statement :
Depending on certain conditions, few statements are executed.
if-else Statement :
Depending on a condition;( if true or false), statements are executed.
We all have made many decisions in life. (Here, decisions do not mean a big decision.)Most of our decisions depend on different conditions..isn’t it?
some situations in which you had to make a decision?
● What to order in a restaurant?
● What to do in my free time?
● Which movie to watch?
● Which subject to take an elective?
● During exams, which question to attempt first? Depending on where you are going, the dress you select to wear will also change ..isn’t it? So let's try an activity. Select the dress, according to a given condition.
1. If going to a party
2. If going out for playing
3. If going swimming
4. If it's cold outside
5. If going to school So here depending on the condition, you are deciding what to wear. Similarly in coding also, we have to make certain decisions or depending on certain conditions, some processing has to be done.
Results are out and you found that you have scored above 85%. You get Rs 100/- from your mother. Now the difficult part comes - which ice cream to buy ?!!!. Butterscotch Ribbon(2nd choice) and Melted Chocolate Fudge(1st choice) are your favorites. You decide to check the cost of ice cream and buy it.
Write a program to get the cost of ice creams and print which one to buy.
Let's Write a program to simulate this.
1 -Small or Regular
2- Double
3 or 4 - Family Pack
5 or 6 -Happiness Pack
>6 - Print the entire options and ask them to select
Comments
Post a Comment