2

That's because you're trying to store the character at the 1st index of a char array (string), node, into an int variable directly, without converting it into an int first. So the 5 in your example is being treated as the character '5' and not the integer 5, and like storing any other character into an int variable, its ascii value gets stored in octave1.


2

I can't tell if actualIncrease3 is a function or an integer variable. It is declared inside of the frequency() function as an integer by this: int actualIncrease3; Later, in lines 108 to 122, it appears that you're trying to create a function called actualIncrease3 that returns an integer. If so, then a review of how to create functions is in order. A ...


2

My sincere recommendation is ... start again. You have two nested loops, each time the DO-WHILE loop begins, the min and max values are set to zero, as the end-of-cycle condition for while is values[min] > values[max] can occur at any time or never happen, so we can have an infinite loop, also you are changing the values of the array itself so that your ...


2

Your main() doesn't have a body, and so the use of printf() is considered a separate declaration of a new function, which also doesn't have a body. The fact that the body is missing is because you don't have curly braces after main(). Your code should be more like: #include <stdio.h> int main(void) { printf("This escape sequence moves the cursor ...


2

In testing, the code works fine. Is it possible that you have a problem with your sort function? Have you verified that sort is correct by printing out the sorted list with different test data? As a side note, I am curious why you decided to write binary_search() the way you did. Specifically, search returns a bool, while binary_search returns an int. Your ...


1

OK, first your sort() is definitely wrong. By saying values[i]=values[j], doesn't mean that those two values are exchanged, so now both values[i] and values[j] have the value that values[j] had. Take a closer look at how bubble sort works at Wikipedia. Your search() on the other hand, is mostly correct from what I can see, except three places. If n is ...


1

Victory! I figured out the problem and I don't really know why it fixed it. I moved the declaration of int end and int start to just above the while clause. I left the declaration of int middle inside the while clause. And like that the infinite loop stopped and all the tests came back correct. How can such a little thing make such a big difference?


1

It seems that your search program has an infinite loop, it is almost always the fault of the end condition while loop, make sure that the loop breaks at some point, I suspect the program will work if we change the condition to something a little more readable: while (start <= end)


1

If they are not swapped, the puzzle is not solvable. You can review the Wikipedia article about the game to learn about the arcane mathematics "happening behind the screen".


1

In your swap part, you assign to values[j] twice, second should be values[j+1]


1

You have two problems with the last element, or the one just behind the array. In code for(i = 0; i < n && no_swap == false; i++) { no_swap = true; for(j = 0; j < n - i; j++) { if (values[j] > values[j + 1]) { tmp = values[j]; values[j] = values[j + 1]; values[...


Only top voted, non community-wiki answers of a minimum length are eligible