Basic Programming Course: Lesson #3; Operations

in #devjr-s20w3last month
Black Gold Elegant Jewelry Logo_20240926_231521_0000.png
edited with canva

Hello friends and welcome to my article in the SEC S20/W3 in this great dynamic I would be sharing my thoughts immediately.


Give a summary of what arithmetic and logical operations are used for

ARITHMETIC OPERATIONS

This is used for basic calculations such as addition + subtraction - division / multiplication * and other expressions which include exponentiation ^ amidst others. It is basically used to incompetent these mathematical parameters to program.

  • Addition: To sum two or more values we use + In a scenario in which I have to add up the values 8 and 6 it would be displayed in a program format below thus:
Screenshot_20240926-071144.png
  • Subtraction: To interprete this - we remove one value from another. Scenario in this case we use the same variables 8 minus 6 in cases where two values are to be removed from each other as shown below thus:
Screenshot_20240926-071321.png
  • Multiplication: We must multiply two values using the special command* This is what we use. If we want to multiply 12 by 4 12*4=48

  • Division: To perform division, we have to be the division sign / If we want to divide two numerical values say 8/4= 2

Screenshot_20240926-071758.png
  • Module: This is usually the remainder after the division has taken place. It could be a whole number, fraction or decimal. For instance if 9 divided by 2 it would be 4 remainder ½ or 0.5. I would be using % to operate during the division process.
Screenshot_20240926-072456.png

COMPARISON OPERATIONS

For comparison operation to take place two or more variables must be put in place. Which would return a true or false (Boolean result). Examples of these comparison operative would be explained below thus;

Greater Than (>):
This is the operator sign that tells us the greater value between two numerical values. Scenario; 10 is greater than 2 the result would be 10>2

Screenshot_20240926-072903.png

Less Than (<):
This is the opposite of greater than, it is a basic operator command which is used in comparison of two variables. Scenario; say between 20 and 10 it would be placed that 10<20 as a function of the less than command.

Screenshot_20240926-211631.png

LOGICAL OPERATIONS

This is used to compare two or more variables at the same time. In other words they enable you create more complex conditional statement which principally affects decision making. The are Boolean expressions used to compare while enhancing decision making. Key facts of the logic operators entails the use of AND, OR If a conditional structure its true and meets all conditions it is false

AND(&&): When both conditions are true it's obvious that we use AND. Picture a girl is fair and tall, the expression would be true because she meets the conditions stated in the scene.
Print "Does user meet both condition? Is_fair and is_tall;

OR(||): If we have two condition, a conditional statement in which a subject does meet some of the complete prerequisite in the statement it is true. But in situation where it nulled all prerequisite in statement it is false.
Print "Does the user meet at least one condition? is_fair or is_tall;


Make a program that asks the user for 2 numbers and evaluates whether both numbers are equal

I would be performing this task on my online IDE a pictographic representation of the task so all can see.

Screenshot_20240926-214203.pngcoded programScreenshot_20240926-214252.pngresult

Transform the following mathematical expressions into arithmetic expression on your computer

First expression "Y"

Y = (8-2)*(5+4)

Simplification: (8-2)* (5+4)= 6 * 9 = 54

So Y = 54


Subsequent expression "x"

x= (8/2) + (5/5)

Simplification: (8/2)+ (5/5)= 4+1 = 5

So x = 5


Subsequent expression "z"

z = ((4+8)*3) / (2 * 3)

Simplification ((4+8)*3) / (2 * 3) =
(12 * 3)/6= 36/6 = 6

So z = 6


Evaluate if the result of the operation are greater than or equal to 0 (>=) and Show it on the screen

all_positive= (x>=0) and (Y>=0) and (z>=0)

Print (F " are x,y,z all greater than or equal to 0? {all_positive})
End Algorithm

Screenshot_20240926-215435.pngcoded program
Screenshot_20240926-215510.pngresult

Cc;
@alejos7ven

I have concluded my article and would be inviting @fombae @chant @ruthjoe @eliany to join challenge
Sort:  
Loading...

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.028
BTC 70213.83
ETH 2453.22
USDT 1.00
SBD 2.38