I am new to C programming. I want to use a while loop to check for the number 500.00 in a line of the ‘grid’ matrix and to go to the next line if it’s not there. For this purpose I wrote this program, but unfortunately it doesn’t show any results and I don’t know what the problem is.
The program that I have written is here:
for(i=0;i<12;i++){
c=0;
for (j=0;j<26;j++){
while(grid[i][j]!=500.00 && c<=ncmax );
c++;
}
printf("%d \n \n",c);
}
I changed the while loop to
while(&grid[i][j]!=500.00 && c<=ncmax );
but it shows these errors
error C2440: '!=' : cannot convert from 'double' to 'float *'
error C2446: '!=' : no conversion from 'double' to 'float *'
What should I do with this problem? In general, am i able to use the while loop like this?
If you need to see the whole program please let me know.
I don’t understand your while. Don’t you want a if instead?
But I think you could go for something simpler:
EDIT:
I just noticed that in the first program,
candjhave the same value. You could simplify to:The output should be the list of
c. It is equals to the minimum of26orncmax+1or the index of the value500.00in the linei.PS: If you know the value of
ncmax, you could simplify the condition.