Answered step by step
Verified Expert Solution
Question
1 Approved Answer
BNF BFN notation def guess : real; def n : real; # Set the input variables guess := 1.0; n := inputReal(); if [ n
BNF
BFN notation
def guess : real; def n : real;
# Set the input variables guess := 1.0; n := inputReal();
if [ n >= 0.0 ] then {
# Continue until the root has been found
while [ abs(guess^2 - n) > 0.01 ] { guess := (n + (n / guess)) / 2; };
# Print the result print("Root is ", guess); };
1. Statement 1.1. There are five types of statements 1 Variable Definition 2) Assignment Statement 3) Conditional Statement 4) Loop Statement 5) A Block of Statements 1.2. Notes . Statements end with a': . A block of statements may be empty 2. Variable Definition 2.1. Example def vi: integer: 2.2. Notes Each variable is defined on its own line There are no initializations * Only the following built-in types are allowed: integer, real, string . Variable names must be all letters (upper or lowercase or any combination) 3. Constants 3.1. Expressions can have constants. 3.2. Examples Integer Examples: 1, 123, 0 Real Examples: 0.12, 1234 String Examples: "Hello World","" 3.3. Notes . We do not recognize escape characters in strings A string can be empty *Real numbers must have digits before and after the decimal point. 4. Expressions 4.1. There are two kinds of expressions, math and boolean. Math expressions are made with constants, other math expressions and math operators. Conditional expressions are made with math expressions and relational operators 4.2. Examples 1. Statement 1.1. There are five types of statements 1 Variable Definition 2) Assignment Statement 3) Conditional Statement 4) Loop Statement 5) A Block of Statements 1.2. Notes . Statements end with a': . A block of statements may be empty 2. Variable Definition 2.1. Example def vi: integer: 2.2. Notes Each variable is defined on its own line There are no initializations * Only the following built-in types are allowed: integer, real, string . Variable names must be all letters (upper or lowercase or any combination) 3. Constants 3.1. Expressions can have constants. 3.2. Examples Integer Examples: 1, 123, 0 Real Examples: 0.12, 1234 String Examples: "Hello World","" 3.3. Notes . We do not recognize escape characters in strings A string can be empty *Real numbers must have digits before and after the decimal point. 4. Expressions 4.1. There are two kinds of expressions, math and boolean. Math expressions are made with constants, other math expressions and math operators. Conditional expressions are made with math expressions and relational operators 4.2. ExamplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started