Sams Teach Yourself C in 21 Days
6: 7: int main( void ) 8: { 9: /* Print the numbers 1 through 20 */ 10: 11: count = 1; 12: 13: while (count <= 20) 14: { 15: ...
Basic Program Control 135 6 You might have noticed that a whilestatement is essentially a forstatement without the initializatio ...
Example 2 /* get numbers until you get one greater than 99 */ int nbr=0; while (nbr <= 99) scanf(“%d”, &nbr ); Example 3 ...
Basic Program Control 137 6 20: printf(“\nEnter number %d of 5: “, ctr + 1 ); 21: scanf(“%d”, &nbr ); 22: } 23: 24: array[ct ...
This outer loop continues to execute while ctris less than 5 (line 15). As long as ctris less than 5 , line 17 sets nbrto 0 , li ...
Basic Program Control 139 6 The structure of the do...whileloop is as follows: do statement while (condition); conditionis any C ...
Listing 6.5 shows an example of a do...whileloop. LISTING6.5 do.c. A simple do...whileloop 1: /* Demonstrates a simple do...whil ...
Basic Program Control 141 6 1 - Add a Record 2 - Change a record 3 - Delete a record 4 - Quit Enter a selection: 4 You chose Men ...
Ado...whilestatement is a C looping statement. It allows repeated execution of a state- ment or block of statements as long as t ...
Basic Program Control 143 6 } /* end of for loop */ }while (x != 0); If the do...whileloop is placed entirely in the forloop, th ...
Nesting is the placing of one command within another. C allows for the nesting of any of its commands. Nesting the ifstatement w ...
Basic Program Control 145 6 Is it true that a whilestatement can be used and still get the same results as coding aforstatement ...
10 448201x-CH06 8/13/02 11:20 AM Page 146 ...
DAY 7 WEEK 1 Fundamentals of Reading and Writing Information In most programs you create, you will need to display information o ...
Displaying Information On-Screen .................................................................... You will want most of your ...
Fundamentals of Reading and Writing Information 149 7 start of the next line.” Escape sequences are also used to print certain c ...
Table 7.1 lists C’s most commonly used escape sequences. Listing 7.1 demonstrates some of the frequently used escape sequences. ...
Fundamentals of Reading and Writing Information 151 7 45: 46: }while ( selection < 1 || selection > 3 ); 47: 48: return se ...
Theget_menu_choice()function is defined in lines 31 through 49. This is similar to the menu function in Listing 6.5. Lines 37 an ...
Fundamentals of Reading and Writing Information 153 7 TABLE7.2 The most commonly needed conversion specifiers Specifier Meaning ...
«
4
5
6
7
8
9
10
11
12
13
»
Free download pdf