Ossama Memon · December 24, 2015 Please Help. I can't understand if statement in this tutorial. How is it working in this program? Please reply as soon as possible... Thank you...

## Replies

 Linguist Llama · December 25, 2015 Consider that a computer programming language is a sequence of instructions for a computer to follow. It's analogous to a cooking recipe.In all languages, there are language structures. Cooking languages typically have two: sequence and repetition. When steps appear one after another, that is sequence, the most basic to understand of language structures.The sequence language structure also exists in programming languages. We write our programs as a sequence of instructions to be executed in order. The next language structure is selection (the one you've asked about). As an analogue, consider what you do when you go shopping for fresh produce at the supermarket. You inspect the produce, if it has any signs of decay you put it back. Otherwise you put it into your basket. You could write this as:``if (produce is rotting) { throw it at the staff}else { put it in your shopping basket}``In cooking recipes, we also have statements like "heat at 180 celsius for 60 minutes or until golden brown". The structure of this statement is repetition. It implies that you need to repeatedly check the temperature, until you've determined that it is 180 celsius (or we preheat for fifteen minutes if we don't have a thermometer in our ovens)... Then it implies that you need to repeatedly check the time (or visually inspect the food) to determine whether it's cooked. We could write such statements like:``while (temperature < 180) { if (oven isn't lit) { light oven; }}put food in ovenwhile (food isn't burnt) { go shopping}``... and we will finish shopping only after our food is burnt Makes sense? Ossama Memon · December 26, 2015 Linguist Llama. It really makes Sense and seriously I enjoyed your answer . But I think you are trying to teach me about if else and while statements. I know these. I just couldn't understand the working of if statement in this program. By the way thanks for the answer
• 1

## C

128,087 followers