Conditionals - Conditionals Darin Brezeale The University of Texas at Arlington Conditionals p.1/22 Basic Concepts Conditionals Conditionals are

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Conditionals Darin Brezeale The University of Texas at Arlington Conditionals – p.1/22
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic Concepts – Conditionals Conditionals are used for making decisions. The conditionals available in C are if and if-else statements the switch statement the conditional expression operator, ?: Conditionals – p.2/22
Background image of page 2
Operators – Relational The following relational operators are available in C: == equality != not equal < less than > greater than <= less than or equal to >= greater than or equal to Conditionals – p.3/22
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Conditionals – if The basic format of the if statement is if (condition_is_true) do_something; Examples if (x >= 2) y = 10; if (y == 10) printf("y is now 10"); Conditionals – p.4/22
Background image of page 4
Conditionals – if cont. Question: What if we want to do more than one thing in response to a condition being true? Answer: Create a block of statements. Example if (x >= 2) { y = 10; printf("y is now 10"); } Conditionals – p.5/22
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if cont. What if we wish to have a second conditional statement in response to the first condition being true? We can nest the if statements. Example if (count > 23) if(time < 45) z = 56; This assigns a value of 56 to z only if count > 23 and time < 45 . Conditionals – p.6/22
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/12/2011 for the course JAVA 2312 taught by Professor Darinbrezeale during the Spring '11 term at University of Texas at Austin.

Page1 / 22

Conditionals - Conditionals Darin Brezeale The University of Texas at Arlington Conditionals p.1/22 Basic Concepts Conditionals Conditionals are

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online