Basic programming course: Lesson #3 Operations

in #devjr-s20w32 months ago (edited)

steemit-engagement-challenge-cover.jpeg

Greetings Steemit friends

Give a brief summary of what arithmetic, comparison, and logical operations are for.

Operations are used either for mathematical calculations or for the control and analysis of data. As mentioned, we have arithmetical operations, comparison operations, and logical operations.

Arithmetic operations are addition, subtraction, multiplication, division, modulus, and exponentiate. They are mostly used for mathematical calculations, and the primary character used is an integer.

+, -, *, /, %, **

Example

  • Addition

Algoritmo Addition
Define number01, number02 as Integer
Print "Enter first Number";
read number01;
Print "Enter Second Number";
read number02;
result= number01 + number02;
Print "The first number + second number = " result
FinAlgoritmo

Screenshot 2024-09-24 190059-add.jpg

Comparison operations are used to compare two values, with the aim being to return a boolean value. This operation is used to give results that are either true or false.

== : Equal to
!= : Not equal to
> : Greater than
< : Less than

Example

Algoritmo Addition
Define number01, number02 as Integer
Print "Enter first Number";
Read number01;
Print "Enter Second Number";
Read number02;
If number01 != number02
Print "The first number is not equal to the second number"
Else
Print "The first number is equal to the second number";
Endif
FinAlgoritmo

Screenshot 2024-09-24 190655-not-equal.jpg

Logical Operations are used to compare more than one boolean expression to make complex decisions. Example && (AND) and ! (NOT).

Algoritmo Logical
Define number01, number02 as Integer
Print "Enter first Number";
Read number01;
Print "Enter Second Number";
Read number02;
If number01 > 1 AND number02 > 1
print "Both numbers are greater than 1"
Else
print "Both numbers are not greater than 1";
Endif
FinAlgoritmo

Screenshot 2024-09-24 194813-logic-1.jpg

Screenshot 2024-09-24 194813-logic.jpg

Make a program that asks the user for 2 numbers and evaluates if both numbers are the same.

For us to achieve our result, we need to first by assigning two variables to hole the two numbers that will be compared. Here I will be using a comparison operation to check if the two numbers are the same.

Screenshot 2024-09-24 164432.jpg

Screenshot 2024-09-24 164526.jpg

Screenshot 2024-09-24 164608.jpg

Transform the following mathematical expressions into arithmetic expressions on your computer:

To make it simple for me, I will break the mathematical expressions into small blocks and make them easy to manipulate in the program. I will be using b in place of y. y is an operation, following the language used on the PSeInt app.

Screenshot 2024-09-24 203939.jpg

Algoritmo Question3
Define y, x, z Como Real;
y = (8-2)(5+4);
Print "Result:" y;
x = 8/2 + 5/5;
Print "Result: " x;
z = (4+8)
3/2/3;
Print "Result: " z;
//Let's evaluate the three results
If y >= 0 Then
Print y " is great than Zero(0)";
Else
Print y " is not great than Zero(0)";
Endif
If x >= 0 Then
Print x " is great than Zero(0)";
Else
Print x " is not great than Zero(0)";
Endif
If z >= 0 Then
Print z " is great than Zero(0)";
Else
Print z " is not great than Zero(0)";
Endif
FinAlgoritmo

Screenshot 2024-09-24 185136.jpg

Screenshot 2024-09-24 185305.jpg



Cheers
Thanks for dropping by
@fombae

Sort:  
Loading...

Wow you have already dropped your entry I have also invited you to join this contest but you have won by dropping your entry already. You have demonstrated each question in a good way. Interesting explanation and details of all the programs. Best wishes and have a good day.

hahahahahaha, I had the chance. So quickly drop. It is quite a busy period for me, but I will always find time to learn. Thanks again for calling my attention to this contest. Not to forget, Courage with the work you doing. I know what it means to carry on with a Dev course.

You are awesome. And thanks for your appreciation and best regards.

Your post has been rewarded by the Seven Team.

Support partner witnesses

@seven.wit
@cotina
@xpilar.witness

We are the hope!

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.034
BTC 89422.86
ETH 3144.72
USDT 1.00
SBD 2.76