I want to enter n number of elements to an array from the user but it does not take an input after 1 element and prints only that element and terminates and does not print the whole array.dont know why it is not working even though there isn't any error.
#include <stdio.h>
int main()
{
int arr[100] = {1, 2, 3, 4, 5};
int n, q, m = sizeof(arr) / sizeof(arr[0]);
printf("enter the number of elements to be added:");
scanf("%d", &n);
q = m + n;
for (int i = m; i < q; i++)
{
printf("enter the number:");
scanf("%d", &arr[i]);
}
for (int i = 0; i < q; i++)
{
printf("%d\t", arr[i]);
}
return 0;
}
this is how it appears at the terminal:
enter the number of elements to be added:3
enter the number:1
1
PS C:\Users\new user\code\c tutorials>