Basic Programming Course: Lesson #4 : Control Structures; Part 1

in #devjr-s20w42 months ago
Black Gold Elegant Jewelry Logo_20241004_224656_0000.png
edited with canva

Hello friends and welcomes to my article once again in the SEC S20/W4 in this great task. I would be putting up my article properly. I do hope you enjoy my article.


Describe your understanding of conditional structures and mention 2 situations of everyday life where you could apply this concept

Conditional Structure is a programming concept which involves execution of different programmed command based on principal conditional statement basically being true or false. The commonly used is the if-else statement. The structure allows program perform different actions depending on any condition, thus have a crucial role in decision making.


Situation of everyday life of conditional structures


1. You intend to be punctual to work, you wake early and prepare yourself early too, to beat traffic as be punctual at work after all. Else you just have to rest and arrive work when you wish.

Screenshot_20241004-220151.png

2. You making pasta for dinner , you make to a good boil for 10 minutes, sieve it for a sweet egg sauce, otherwise keep boiling until its done.

Screenshot_20241004-220639.png

The above two conditional structures are based on decision making to suit your activities as you indeed will.


Create a program that tells the user "Welcome to the room. What do you want to do? If the user writes 1 then it shows a message that says "you have left the room." Use conditonals

Screenshot_20241004-221240.png

The room() function starts by printing welcome and providing 2 options which are 1 and 2. Conditional statement `if-elif-else' checks whether user input is either option 1 or option 2 while showing message as stated earlier. This is there is an error, it would be definitely spotted in the code.

Coded Program

Screenshot_20241004-221546.png

Coded Output Interpretation

Screenshot_20241004-221959.pngScreenshot_20241004-221931.png

Create a program that asks the user for 4 different ratings, calculator the average and if it is greater than 70, it shows a message saying that the section passed, if shows a message saying that the sector can improve

Screenshot_20241004-223700.png

This is the created program with about four inputs from the user with four grades. The average will tell us and display whether it is passed or needs to be improved . We check if average grade is more than 70 then get a message displayed. "The section passed." If it's average goes below 70 then the program displays "section can be improved."

Screenshot_20241004-223733.pngpassed section
Screenshot_20241004-223759.pngimproved section

Cc;
@alejos7ven

I invite @ruthjoe @simonnwigwe @eliany @josepha to join challenge
Sort:  
Loading...

Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.

can i ask, what application do you use .. @daprado1999 ...

I used C++ Online IDE, to run most of the codes, thanks for stopping by and warm regards

Thank you. I guess I will give it a look. Good luck with the contest, and happy weekend.

Coin Marketplace

STEEM 0.22
TRX 0.27
JST 0.041
BTC 104601.56
ETH 3878.85
SBD 3.32