
Originally Posted by
rstanley
5 is passed but you are re-assigning the value with 0 in the for loop.
Thanks for clearing doubts
This is my code to print array
Code:
#include <stdio.h>
int main (void)
{
int i, array[] = {1,2,3,4,5};
for (i = 0; i < 5; i++)
{
printf("array element : %d \n", array[i]);
}
return 0;
}
just now changed line inside the loop. I wonder why the line inside the loop printing the values form 0 to 4
Code:
#include <stdio.h>
int main (void)
{
int i, array[5] = {1,2,3,4,5};
for (i = 0; i < 5; i++)
{
printf("array element : %d \n", array[5]);
}
return 0;
}
Code:
array element : 0
array element : 1
array element : 2
array element : 3
array element : 4