Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in C: How to change the code at the very bottom to look exactly like the code th

ID: 3822808 • Letter: I

Question

in C: How to change the code at the very bottom to look exactly like the code that are in bold below? Do not use BREAK and fflush(stdin) .Also the code should

Sets invoking appropriate error messages, e.g., too many values or invalid character data. The invalid characters and extra values will need to be flushed, else they will end up in the second array. Have the program continue as normal after flushing the bad data.

Int r;

double value

while((r=scanf(“%lf”, &value))==1 && ptr<endptr)

            *ptr++==value:

If(r==1)

            Printf(“entered more than %i values”, max);

Else if (r !=EOF)

            Printf(“invalid character data entered”)

the code that need to change is below

int table_fill(int A[],int m,int sentinel) //function to read array of values
{
int *a=A;
int i;
int n=0; //variable declarations

printf("Enter integer values :(Max values to be entered is %d)(-999 to stop)"); //prompting input
i=0;
while(i>=0) {
scanf("%d",&n); //reading number
if(n==-999)break;
a[i]=n; //assigning to array
i++; //incrementing
}

return i;

Explanation / Answer

You can use below code for it

while(scanf("%d",&n) && n!=-999)
{
     a[i]=n;
    i++;

}

Let me know in case its not understood. Thanks