Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 6 - Programming Languages - Section 6.2 - Traditional Programming Concepts - Questions & Exercises - Page 292: 4

Answer

In a program, a control structure determines the order in which statements are executed. The following are the basic control structures in the programming languages: Sequential In Sequential execution each statement in the source code will be executed one by one in a sequential order. This is the default mode of execution. Selection The selection control structure is used for making decisions and branching statements; the following are the basic selection statements in the programming language. if: The If statement checks for the condition and if the condition is satisfied it executes the statements in the “if” block, otherwise it exits the “if” block. Syntax: \begin{equation} \begin{array}{l}{\text { if (condition) }} \\ {\text { \{ }} \\ {\text { statement }} \\ {\mathrm{~ \} ~}}\end{array} \end{equation} if-else: If-else statement is used to execute any of the two blocks of statements, if the condition satisfies it executes the statements in the “if block”, otherwise it executes the “else block”. switch case: Switch statement is used when a variable is to be checked for equality in a list of values. _______________________ Iteration The iterative control structures are used for repetitively executing a block of code multiple times; the following are the basic iterative control structures. for: A for loop executes the statements for a specific number of times mentioned in the condition. while: A while loop executes statement repeatedly until the condition satisfies. do-while: A do-while loop works similar to while loop, the only difference is it executes the statement once before checking the condition.

Work Step by Step

In a program, a control structure determines the order in which statements are executed. The following are the basic control structures in the programming languages:
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.