A word used to introduce a hypothetical assumption.Usually followed up at some point with a "then", although sometimes this is left implied.
If (often IF) is also the common name used for If: Worlds of Science Fiction, a science fiction magazine that published short stories and novellas from 1952-1972. The name changed in 1972 to Worlds of If. Under the new title, IF continued until 1986. (During the years 1975-1985 no issues were put out.)
IF was the first to get hold of Keith Laumer's Retief stories and Fred Saberhagen's Berserker stories. IF also had some big name editors; Frederick Pohl, Damon Knight and Horace Leonard Gold.
If
If you can keep your head when all about you Are losing theirs and blaming it on you; If you can trust yourself when all men doubt you, But make allowance for their doubting too: If you can wait and not be tired by waiting, Or, being lied about, don't deal in lies, Or being hated don't give way to hating, And yet don't look too good, nor talk too wise;
If you can dream---and not make dreams your master; If you can think---and not make thoughts your aim, If you can meet with Triumph and Disaster And treat those two impostors just the same: If you can bear to hear the truth you've spoken Twisted by knaves to make a trap for fools, Or watch the things you gave your life to, broken, And stoop and build'em up with worn-out tools;
If you can make one heap of all your winnings And risk it on one turn of pitch-and-toss, And lose, and start again at your beginnings, And never breathe a word about your loss: If you can force your heart and nerve and sinew To serve your turn long after they are gone, And so hold on when there is nothing in you Except the Will which says to them: "Hold on!"
If you can talk with crowds and keep your virtue, Or walk with Kings---nor lose the common touch, If neither foes nor loving friends can hurt you, If all men count with you, but none too much: If you can fill the unforgiving minute With sixty seconds' worth of distance run, Yours is the Earth and everything that's in it, And---which is more---you'll be a Man, my son!
if ( condition ) { expression1; ...; }
Let's analyse this a little more. The condition can be evaluated into one of two values - true or false. Hence, the two simplest if statements are like this -
if ( true ) { printf("This will *always* be true.\n"); }
if ( false ) { printf("This will *always be false.\n"); }
In the case of the second example, your compiler will most likely flag this with a warning or error, saying the expression will never be executed. The above two examples obviously aren't any use, and don't show us anything about why conditional branching is so useful.
The reason conditional branching is so useful is because it allows us to make run-time decisions that could not be made at compile-time. For instance, we may ask a user to input a value, then we'd want to take action based on this value. We could use a construct similar to this -
if ( value < 0 ) printf("Please input a value larger than or equal to 0.\n" );
So, to analyse this statement: If value is smaller than zero, then the conditional of the if evaluates to true, and therefore the expression is executed. In any other case (if the value is equal to or greater than zero), the conditional evaluates to false, and the expression is not executed.
You can see that being able to execute different instructions based on the values of data opens up many more possibilities than linear programs which do the same thing every time they're run!
Other if-based constructs are the if/else construct and the if/elseif construct, which look like this -
If/else construct-
if ( value > 0 ) { printf("The value is larger than zero.\n"); } else { printf("The value is not larger than zero.\n"); }
If/elseif construct-
if ( value == 2 ) { printf("Value is equal to 2.\n"); } else if ( value == 3 ) { printf("Value is equal to 3.\n"); }
Transcribed from a video recording made at the National Poetry Slam 1999 in Chicago, IL -- http://www.livepoets.com/shaneif.ram, with corrections made from a 'Perfect' recording courtesy of Pseudo_Intellectual.
I could slit my wrists on your shoulderblades and offer you my pulse... Because this feeling isn't true or false -- this feeling is If.
If I, If I could. If I could have said have said something I could've would've should've said, 'stay.' 'Stay,' was the word I was trying to say stay that night at the party when you pulled me away out on the sidewalk to talk to tell me you were going away I was trying to say, 'stay.'
But I was too busy contemplating the ifs.
But if that was my darkest hour then these are my finest seconds because now I can say that I could've would've should've said something, could've would've should've said anything, could've said,
'I can scoop out my intestinal track, fill it with helium gas and make a balloon animal for you.'
Would've said, 'If you were tired of cute I would cook the Pillsbury Doughboy alive'. If the directions said three minutes I'd cook him for five.
Should've said. If.
If I, if you, if we... The largest part of any equation begins with 'if' followed by time. And I know we're no math scholars but God, we should've calculated the ifs.
So that I, so that you, so that we could've would've should've prepared for whatever if had in store if if had anything at all. Because if you died before me and I mean if that's the way it had to be then we'd have no choice.
But to declare with one single voice, one voice that could shake the ground. One voice that could make God Himself look around and say, 'What was that sound?'
And I'd turn His kingdom into a chalkboard, that's right, I'd throw God into my detention just to make Him write down what I didn't mention -- because He'd have to cut me a deal.
Because I didn't get to tell you how I feel. And I would make Him dictate my words like they were flying to heaven on the backs of dead birds but if wasn't going to help me, if he was just going to sit there like dust on a bible, like a bible on a shelf then fuck Him because I will do it myself and I will make it rain tears for eighty days and eighty nights, because I know love travels faster than light.
And all I'd have to do is whisper.
Because if if had anything at all then I was not pushed and I did not fall, I jumped out of grace and I landed on my face because there was no safety net...
But don't draw a chalk outline around my body yet because if if had anything at all, if I was in hell I'd still give you a call because even if this is the greatest poem that I ever wrote I'd still have to write a little sidenote saying, 'It is not enough simply to say I love you.' That kind of shit just ain't gonna do, because if the universe has no beginning, has no end, has no bottom, has no top, I would jump from somewhere, I would drop through infinity, because I'm not just saying I love you.
I'm saying I'll never stop.
Consider the following: I have promised George that if I find $10.00 on the ground then I will treat him to a movie.
Under the following cases:
So, the "truth table" for an if statement evaluated as a whole is as follows:
"(If A then B) = Result (or R)" ------------- | A | B | R | ------------- | T | T | T | | T | F | F | | F | T | T | | F | F | T | ------------- T = True; F = False
This is a useful way of determining if one variable is dependant on another. In the above scenario, the two events are independent. When the two variables are dependant (B is directly based on the state of A) the "if truth table" looks like this:
"If (A) then B" --------- | A | B | --------- | T | T | | F | F | ------------- T = True; F = False
For example, if you are tuned to Wild FM at 89.7 MHz, in many FM receivers, the RF energy will be downconverted to about 10 MHz, before it hits the FM circuitry.
Microwave circuitry requires the signal to be upconverted over several stages to reach the high frequencies of the UHF band, 2 - 20 GHz.
If (?), conj. [OE. if, gif, AS. gif; akin to OFries. ief, gef, ef, OS. ef, of, D. of, or, whether, if, G. ob whether, if, OHG. oba, ibu, Icel. ef, Goth. iba, ibai, an interrogative particle; properly a case form of a noun meaning, doubt (cf. OHG. iba doubt, condition, Icel. if, ef, ifi, efi), and therefore orig. meaning, on condition that.]
1.
In case that; granting, allowing, or supposing that; -- introducing a condition or supposition.
Tisiphone, that oft hast heard my prayer, Assist, if oedipus deserve thy care. Pope.
If thou be the Son of God, command that these stones be made bread. Matt. iv. 3.
2.
Whether; -- in dependent questions.
Uncertain if by augury or chance. Dryden.
She doubts if two and two make four. Prior.
As if, But if. See under As, But.
© Webster 1913.
printable version chaos
Everything2 Help