ELEC 209 Lecture Notes - Lecture 5: Infinite Loop, Scanf Format String

19 views2 pages
2 Feb 2020
Department
Course
Professor

Document Summary

Iteration statements: c provides three iteration statements: The while statement is used for loops whose controlling expression is tested before the loop body is executed. The do statement is used if the expression is tested after the loop body is executed. The for statement is convenient for loops that increment or decrement a counting variable. Loop structures while loop int number = 5; while (number>0) printf( %d, ,number); number--; Loop structures do-while loop int number; do { printf("enter a number (enter 0 to quit): ); scanf( %d ,&number); printf("you entered: %d\n ,number); For statement idioms: the for statement is usually the best choice for loops that. Count up (increment a variable) or count down (decrement a variable): a for statement that counts up or down a total of n times will usually have one of the following forms: Counting up from 0 to n 1: for (i = 0; i < n; i++) .

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents