Hi guys
this is what I want the program to do:
it's to save up to 100 given number>0 from keyboard in some Array. If the given number is smaller than 0, it should stop and give back all the numbers inserted up to then, but backwards. so it gives out all the numbers saved in the array from the last typed number to the first one.
this is my idea which apparently doesn't work. and I can't see the reason..I'd be thankful for any hint
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
int number [100]={}; //"number" is just a name for the array
printf("give a number!\n");
scanf("%d",&i);
while(i>0){
number[100] = i; //saves the number in the array?
getchar();
if(i<0)
break;
}
printf("%d",number[--i]);
putchar('\n');
return EXIT_SUCCESS;
}