DEV Community

lost ruins
lost ruins

Posted on

Vector problem

#c

Hello, I tried to print the first and the last numbers of a vector, but for some reason only the last number is saved in it. What is exactly wrong with this code?

int main()
{
int n[10],i;

for(i=0;i<10;++i){
    printf("Input 10 numbers: ");
    scanf("%d",&n[i]);
}
printf("First: %d\nLast %d",n[0],n[9]);

return 0;
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)