Part 4 Correct errors in program . ( 1 0 points in total): 1) ( 5 points) The fo
ID: 3740678 • Letter: P
Question
Part
4
Correct
errors in program
.
(
1
0
points in total):
1)
(
5
points)
The following program is used to
display numbers between two intervals
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include stdio.h
#define true 1
#define false 0
void prime(int low, int high){
int i =0, flag=0;
printf("Prime numbers between %d and %d are: ", low, high);
while (low < high)
{
flag = false;
for(i = 0
; i <= low/2; ++i)
{
if(low % i == 0)
{
flag = true;
break;
}
}
if (flag ==
true
)
f("%d ", low);
++low;
}
printf("
n");
}
int main()
{
int low, high;
printf("Enter two numbers(intervals): ");
scanf("%d %d", low,
high);
prime.
prime(low,high);
return 0;
}
Which line
(s)
is
(are)
incorrect?
And how to correct it
(them)
? Please write down your
correction
for that
line (those lines)
Explanation / Answer
Errors
Scarf is wrong variable address must be used to avoids segment violation error
Unnecessary prime word in main function
Printf are spread over multiple line in prime function
For loop spread over three line in prime function
Invite loop since low increments happens inside if condition
I should be initialised with 2not 0