Int r; double value while((r=scanf(“%lf”, &value))==1 && ptr *ptr++==value: If(r
ID: 3822143 • Letter: I
Question
Int r;
double value
while((r=scanf(“%lf”, &value))==1 && ptr
*ptr++==value:
If(r==1)
Printf(“entered more than %i values”, max);
Else if (r !=EOF)
Printf(“invalid character data entered”)
In C: How to change the code below to look like the code above with out using BREAK.
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
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)",m); //prompting input
i=0;
while(scanf("%d",&n)!=-999) {
//printf("%d ",n);
if(n==-999)break;
a[i]=n; //assigning to array
i++; //incrementing
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.