I was trying to get input from keyboard and place it in array. If the user input is -1, the program should end itself. This thing really work. The requirement i wanted is,
- -1 is used to terminate<<----work
- -1 will not be stored in array<<----not really
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int num[]={};
int count=0;
double total=0;
int count2=1;
printf("Input Value into Array\n");
while(num[count]!=-1){
count++;
printf("value:");
scanf("%d", &num[count]);
total = total + num[count];
count2++;
}
printf("Total count: %d\n",count);
printf("Value inserted: ");
for(count=1;count<count2;count++){
printf("%d ",num[count]);
}
}