Computer Science, asked by Ananayaduba, 5 hours ago

Write algorithm for the following problems.
1. To add two numbers.
2. To find out if a number is even or odd.​

Answers

Answered by Anonymous
146

Algorithms

The step by step description of cօde logic that helps us to write the cօde that is known as algorithm. It is written in simple and easy language.

Here's our algorithm to add two numbers.

Step 1: Take two number inputs or declare variables.

Step 2: Add both the two numbers using the addition operator.

Step 3: Assign the result.

Here's our algorithm to find out if a number is even or odd.​

Step 1: Take any number input  and store it in a variable [Suppose that here we have taken 'num' as a variable] or a declare variable.

Step 2: Check if num % 2 == 0 then it is a even number or else the number is odd.

Step 3: Assign the result.

\rule{200}{1}

Extra info

Here's some operators that are mainly used in programming:

\boxed{\begin{array}{c|c|c}\bf{\underline{ \:Operator \: }}&\bf{\underline{ \:N ame \: }} & \bf{\underline{ \:Example\: }} \\ \\+ & \tt Addition & \tt x + y \\ \\- &  \tt{Subtraction} & \tt x - y \\ \\ * & \tt Multiplication & \tt x * y \\ \\ / & \tt Division & \tt x / y \\ \\ \% & \tt Modulus & \tt x \% y \\ \\ * * & \tt Exponentiation & \tt x * * y \\ \\ // & \tt {Floor \; division} & \tt x // y \\ \\\end{array}}

Similar questions