Write a C Program
Consider the following program fragment:
1. i = 1; sum=0;
2. while (i <= n) do
begin
3. sum = sum + a;
4. i = i + 1;
end
Let
A represent the initialization in line 1
B represent the action within the loop in line 3
I represent the increment in line 4
T represent the test implied by line 2
Which of the following regular expressions represents all possible sequences of steps
taken by this program? Justify your answer.
I. A(TBI)*
II. AT+B*I*
III. AT(BIT)+
IV. AT(BIT)*
V. A(TBI)+
1. i = 1; sum=0;
2. while (i <= n) do
begin
3. sum = sum + a;
4. i = i + 1;
end
Let
A represent the initialization in line 1
B represent the action within the loop in line 3
I represent the increment in line 4
T represent the test implied by line 2
Which of the following regular expressions represents all possible sequences of steps
taken by this program? Justify your answer.
I. A(TBI)*
II. AT+B*I*
III. AT(BIT)+
IV. AT(BIT)*
V. A(TBI)+
0