13.07.2015 Views

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.8. BRANCHES FOR DECISIONS Page 25Figure 2.2: Calculating the Factorial for a float2.8 Branches for DecisionsDecisions are made by the usage <strong>of</strong> the if statement. The if statement is defined as follows.if [boolean expression 1]:code block 1elif [boolean expression 2]:code block 2elif [boolean expression 3]:code block 3...elsecode block elseThe calculation <strong>of</strong> roots <strong>of</strong> a quadratic equation is a nice and simple example to show the application <strong>of</strong>the if statement. The quadratic equation is given bya · x 2 + b · x + c = 0 (2.8)If we want to solve the quadratic equation, we have to analyze the available cases. A general solutionmust handle the following cases.• constant casea = b = c = 0• linear casea = 0, b ≠ 0• quadratic casea ≠ 0• no solution casea = b = 0 and c ≠ 02.12.2011

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!