Revision- 10
Steps
Input the value of the radius 'r' of the circle.
Define a constant variable 'pi' with the value of 3.14159 (or use the built-in constant Math.PI in programming languages like Java).
Calculate the area of the circle using the formula A = pi * r^2.
The calculated value of 'A' will be the area of the circle.
Finding GCD using Euclid's algo
Steps
Input the two positive integers 'a' and 'b' for which we want to find the GCD.
Initialize two variables, 'x' and 'y', with the values of 'a' and 'b', respectively.
While 'y' is not equal to zero:
a. Set 'temp' equal to the value of 'y'.
b. Set 'y' equal to the remainder when 'x' is divided by 'y'.
c. Set 'x' equal to the value of 'temp'.
The value of 'x' after the loop will be the GCD of 'a' and 'b'.
Steps
Function Declaration
a. Determine the purpose of the function and its return type.
b. Choose a descriptive function name that reflects its functionality.
c. Define the parameters the function requires, specifying their types and names.
Function Definition
a. Begin the function body by specifying the return type (void if no return value).
b. Implement the desired functionality using statements and control flow structures.
c. If applicable, use the return keyword to return a value of the specified return type.
Function Invocation
a. Identify the location in the code where the function should be called.
b. Provide arguments that match the function's parameter list, if any.
Decimal Number System
The Decimal Number System, also known as the Base-10 system, is the number system most commonly used by humans. It is called "decimal" because it utilizes ten distinct symbols or digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each digit's positional value is based on powers of 10. The rightmost digit represents the units place, the next digit represents the tens place, and so on. For example, the number 537 in the decimal system represents (5 x 10^2) + (3 x 10^1) + (7 x 10^0) = 500 + 30 + 7 = 537.
Binary Number System
The Binary Number System, also known as the Base-2 system, is a fundamental number system in computer science and digital electronics. It consists of only two digits: 0 and 1. Each digit's positional value is based on powers of 2. The rightmost digit represents the units place (2^0), the next digit represents the twos place (2^1), the following digit represents the fours place (2^2), and so on. For example, the binary number 101 represents (1 x 2^2) + (0 x 2^1) + (1 x 2^0) = 4 + 0 + 1 = 5 in the decimal system.
In simple terms, the modulo operation finds the remainder after division of one number by another. This operator is particularly useful in various scenarios such as checking for even/odd numbers.
Example: Checking Even or Odd
Problem
Check if a number is even or odd using the modulo operator.
Approach
Read the input number.
Use the modulo operator to determine if the number is divisible by 2.
Print whether the number is even or odd.