this is where the problem is but i cant figure out what (this is not the entire program):
int i, k;
int a[i];
i=0
while(i%26lt;20)
while(k%26lt;19-1)
while(i+k%26lt;20)
for(k=1; a[i] != a[i+k]; k++)
printf("%d", a[i]);
i++;
like i said, this isn't the real program, so don't pay attention to the lack of return 0;, or lack of brackets, they're all there in the real program. the program starts by prompting the user for 20 numbers, then writes them back to the user. However, as soon as its starts the above part of the program, it seems to get stuck in an infinite loop, and after rewriting a couple different ways with similar or worse results, i cant figure out what to do. If anyone could help explain whats wrong here, or better yet how to fix it, i would greatly appreciate it.
C program execution error for delete duplicates from entered array?
The statement incrementing i (i++;) is never reached since the for only works on the printf, thus the outer loop never ends since i never changes. Use curly brackets over both statements.
Who taught you to write loops without brackets? That's a bad habit for a beginner.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment