advertisement

10 examples for if statement

0 %
100 %
advertisement
Information about 10 examples for if statement
Education

Published on March 9, 2014

Author: fyjordan9

Source: slideshare.net

advertisement

Basic Scientific Programming If Statement Examples

Example: Quadratic Equations  Write a program to find the real roots of a quadratic equation AX2 + BX +C = 0 for any given value of A,B, and C.

Example  Write a Nested If structure to print the following: ‘ It is hot !’ when temp is greater than or equal to 90 ‘ It is warm’ when temp is between 70 and 90 ‘ It is cool’ when temp is between 50 and 70 ‘ It is cold’ when temp is below 50

If (temp >= 90) then Print*, ‘it is hot’ Else If (temp >= 70) then Print*, ‘it is warm’ Else If (temp >= 50) then Print*, ‘it is cool’ Else Print*, ‘it is cold’ End if

Example  Write an If/ Else If structure to print the following: ‘ It is hot !’ when temp is greater than or equal to 90 ‘ It is warm’ when temp is between 70 and 90 ‘ It is cool’ when temp is between 50 and 70 ‘ It is cold’ when temp is below 50

If (temp >= 90) then Print*, ‘it is hot’ Else If (temp >= 70) then Print*, ‘it is warm’ Else If (temp >= 50) then Print*, ‘it is cool’ Else Print*, ‘it is cold’ End if

Question  What happens if we swap the 70 and 90? If (temp >= 70) then Print*, ‘it is warm’ Else If (temp >= 90) then Print*, ‘it is hot’ Else If (temp >= 50) then Print*, ‘it is cool’ Else Print*, ‘it is cold’ End if

Add a comment

Related presentations

Related pages

Excel IF Statement – How to Use - Tricking Excel The ...

... the Decision Making statements. Excel IF Statement gives the ... Examples of Excel IF Statement: ... Excel if Statement as: =IF(C2>=8000,C2*15%,C2*10%)
Read more

MS Excel: How to use the IF Function (WS)

... syntax and examples. The Microsoft Excel IF function returns ... examples would return: =IF(A1>10, ... IF statement to handle this. For example ...
Read more

If-then statement (Geometry, Proof) – Mathplanet

Example. Our conditional statement is: if a population consists of 50% men then 50% of the population must be women. $$p to q$$ If we exchange the ...
Read more

3.1. If Statements — Hands-on Python Tutorial for Python 3.1

Simple if Statements¶ Run this example program, ... 10 times to test it, ... A final alternative for if statements: ...
Read more

If Statements in C - Cprogramming.com

If statements allow the flow of the program to be changed, ... Here is a simple example that shows the syntax: if ( 5 < 10 ) printf ...
Read more

Javanotes 7.0, Section 3.5 -- The if Statement

3.5.3 If Statement Examples. As an example of using if statements, let's suppose that x, y, ... i < 10; i++); System.out.println("Hello"); Why?
Read more

For loop - Wikipedia, the free encyclopedia

... (or simply for loop) is a control flow statement for specifying ... or otherwise provide means to alter the for-loop progress; for example in ...
Read more

PHP 5 if...else...elseif Statements - W3Schools Online Web ...

Well organized and easy to understand Web bulding tutorials with lots of examples of how ... Conditional statements are used to ... Top 10 Examples
Read more

The for Statement (The Java™ Tutorials > Learning the ...

This beginner Java tutorial describes ... uses the general form of the for statement to print the numbers 1 through 10 to ... In this example, ...
Read more

for Statement (C++)

for Statement (C++) while ... init-expression and loop-expression can contain multiple statements separated by commas. For example ... int main(){ for (int ...
Read more