hello friends sorry for posting this basic question here but i can't figure it out why my variable "tasse" is getting 8 or (the value of variabale i) in this code below.
#include <stdio.h>
int main(){
int leght = 15;
int tasse =0;
int random;
int array[15]={1,5,4,7,8,5,1,0,9,7,0,0,5,4,10};
int i,j;
for(i=0; i<leght; ++i){
if(array[i]==0){
//increase variable tasse by 1 BUT IT IS GETTING VALUE 8 CAN'T UNDESTAND WHY//
tasse++;
/*FOR J FROM I WE ARE FINDING A VALUE >0 TO EXCHANGE WITH I THIS WORKS WELL*/
for(j=i; j<leght; ++j){
if((array[i]==0)&&(array[j]>0)){
array[i] = array[j];
array[j]=0;
}
}
}
}
leght -= tasse;
printf("Tasse: %d\n", tasse);//here i can see tasse is 8 i can't undestand why
printf("leght: %d\n", leght);
for(i=0; i<leght; ++i){
printf("%d\n", array[i]);
}
return 0;
}