Flow Of Control
(Sumita Arora) Textbook Solutions 7th Edn
credits:openclipart |
SHORT ANSWER QUESTIONS
Q1: What is null statement and a compound statement? What is the alternate name of the compound statement?Answer: The simplest statement is null statement or empty statement. It is represented as just semicolon (;).
e.g. ; // null statement
A compound statement is a sequence of statements enclosed by pair of braces ({}). Alternate name of the compound statement is block.
Q2: What is the significance of a null statement?
Answer: A null statement is useful where the language requires a statement but the program's logic does not.
e.g. a program keeps on reading a value till it encounters a particular value or end-of-file. while (cin >> val && val != required_vale) ;
Q3: What are the three constructs that govern statement flow?
Answer: sequence, selection and iteration
Q4: What is the significance of a test-condition in a loop?
Answer: The test-condition in a loop decides whether the loop-body will be executed or not based on the truth value. If the test-condition evaluates to true i.e., 1, the loop-body will execute, otherwise the loop is terminated.