# 10 examples for if statement

14 %
86 %
Information about 10 examples for if statement
Education

Published on March 9, 2014

Author: fyjordan9

Source: slideshare.net

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

 User name: Comment:

June 17, 2018

June 17, 2018

June 17, 2018

June 17, 2018

June 17, 2018

June 17, 2018

## 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%)

### 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 ...

### 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 ...

### 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: ...

### 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 ...

### 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?

### 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 ...

### 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