#include
#include
#include
int main(void)
{
int t = 5;
int num[t];
for(int i = 0; i < t; i++)
{
num = get_int("enter number");
printf("numbers %d",num);
}
printf("sequence %d",num[t]);
}
Unable to figure out how to get as output the numbers entered for array num[t]. Strange, getting numbers (3,2,7,6,6) instead of desired (7,8,9,10,20) for the above example.
Reply
You don’t get 3,2,7,6,6 … you get the number that is at index 5 which is just outside the array you declared. So it is the number that your program finds in that memory location outside your control.
In order to print from the array you will need a loop similar to the one you used to enter the numbers into the array.
[learn_press_profile]