



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This document introduces program control structures that enable a program to do sequential execution, selection, and repetition. It explains selection and repetition structures, relational and logical operators, and different types of loops. The document also provides some notes and precautions when using loops and discusses nested control structures. suitable for computer science students who are learning programming basics.
Typology: Lecture notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Introduction to Program Control Structures ➢ enable a program not only to do sequential execution but also selection and repetition. ➢ must only be answerable by yes or no
→ Two way selection structure o Block of statements - group of code that is composed of more than one line; enclosing them within curly braces o Precaution for Relational Operator Associativity o Precaution for equality and assignment operator → Multiple Path selection (if-else if)
o If there is no match, the default label would execute. If there is no default label, the entire switch statement would be skipped. o The break statement is used to immediately exit from the switch statement. o The toupper (expression) statement on the switch expression is used to convert the gradeEquiv character to upper case. Repetition Structure ➢ repeatedly execute a statement or a group of statements until the specified condition is met.
o sentinel value - terminate a loop o flag value - a Boolean value that would terminate a loop → for loop - In summary the for loop operates with the following steps
→ continue statement - used skip the rest of the statements on a repetition structure.