@@ -263,60 +263,57 @@ The result is:
263
263
The result is either 0 or 1. Remember, 0 is FALSE and 1 is TRUE.
264
264
265
265
## Conditionals
266
- In a comprehensive program, the computer must decide
267
- based on the condition/s given. Of course, the computer
268
- cannot do that alone, you must instruct it exactly.
269
- The most common is the
270
- IF statement with the extended IF/ELSE.
266
+ In a comprehensive program, the computer must make decisions based on given
267
+ conditions. Of course, the computer cannot do this alone; you must instruct it
268
+ exactly. The most common conditional statement is the ` IF ` statement, often
269
+ extended with ` IF/ELSE ` .
271
270
272
271
### Sample Program Using IF
273
- ```
272
+ ``` c
274
273
#include < stdio.h>
275
274
276
275
int main () {
277
276
int i = 10;
278
277
279
- if (i == 10) printf("Expected value is the same as variable i, so the result is TRUE. \n");
278
+ if (i == 10) {
279
+ printf ("Expected value is the same as variable i, so the result is TRUE.\n");
280
+ }
280
281
281
282
return 0;
282
283
}
283
284
```
284
285
285
- In a single IF statement, the programmer wants to test,
286
- expect or verify something, such as this program.
287
- The programmer is expecting that ` i ` variable
288
- has the value 10, and variable ` i ` has the same
289
- value, so the statement
290
- ` Expected value is the same as variable i, so the result is TRUE. `
291
- will be printed. If the expected value is
292
- not the same as the value of the variable,
286
+ In a single ` IF ` statement, the programmer wants to test, expect, or verify
287
+ something. In this program, the programmer expects that the variable ` i ` has
288
+ the value 10. Since variable ` i ` does have the value 10, the statement
289
+ ` Expected value is the same as variable i, so the result is TRUE. ` will be
290
+ printed. If the expected value is not the same as the value of the variable,
293
291
the statement will not be printed.
294
292
295
- Sometimes, just an IF will not be sufficient,
296
- particularly when you want to catch the FALSE result
297
- or create a nested IF-ELSE. So, you want to extend it
298
- and catch the FALSE result.
293
+ Sometimes, just an ` IF ` statement is not sufficient, particularly when you want
294
+ to handle the FALSE result or create a nested ` IF-ELSE ` . In such cases, you
295
+ extend it to catch the FALSE result.
299
296
300
297
### Sample Program Using IF ELSE
301
- ```
298
+ ``` c
302
299
#include < stdio.h>
303
300
304
301
int main () {
305
302
int i = 10;
306
303
307
304
if (i == 11) {
308
- printf("Expected value is the same as variable i, so the result is TRUE. \n");
305
+ printf ("Expected value is the same as variable i, so the result is TRUE.\n");
309
306
} else {
310
- printf("Expected value is not the same as variable i, so the result is FALSE. \n");
307
+ printf("Expected value is not the same as variable i, so the result is FALSE.\n");
311
308
}
309
+
312
310
return 0;
313
311
}
314
312
```
315
313
316
- Not only the statement in the ELSE branch will be printed,
317
- you can do a lot of things just like correct an error,
318
- go to a certain part of a program, etc. That's the power
319
- of catching the FALSE result.
314
+ Not only can the statement in the ` ELSE ` branch be printed, but you can also
315
+ perform various actions such as correcting an error, navigating to a certain
316
+ part of a program, etc. That's the power of catching the FALSE result.
320
317
321
318
## Loops
322
319
There are commands or portions of your program
0 commit comments