need out put to be like this:
The initial values are 0 0 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 10
The updated array is 10 0 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 94
The updated array is 10 94 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 3
The updated array is 10 94 3 0 0 0 0 0 0 0 0 0.
Enter an integer: 14
The updated array is 10 94 3 14 0 0 0 0 0 0 0 0.
Enter an integer: 21
The updated array is 10 94 3 14 21 0 0 0 0 0 0 0.
what i get is this
The initial values are 0 0 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 10
The updated array is 10 0 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 94
The updated array is 94 0 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 3
The updated array is 3 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 14
The updated array is 14 0 0 0 0 0 0 0 0 0 0.
Enter an integer: 21
The updated array is 21 0 0 0 0 0 0 0 0 0 0.
how do i scan input in and print it in an array so it updates
Code:
int main()
{
int *a1=NULL;
a1=(int *) malloc (SIZE * sizeof(int));
Init(a1);
Updt(a1);
free(a1);
return 0;
}
void Updt(int *a)
{
int i, j, n,x;
do
{
for(i=0; i<SIZE ; i++)
{
printf("Enter an Integer: ");
scanf("%d",& a[i]);
printf("The updated array is: ");
j++;
for(i=0; i<SIZE; i++)
{
printf(" %d ",a[i]);
}
printf("\n");
}
}
while(j < 9);
}