What is the difference between adding a return -1 and a return 1 to any function of type int? Reading the code of a program that was circulating on a forum, in some functions it used return -1 and in others it used return 1.
What is the difference between adding a return -1 and a return 1 to any function of type int? Reading the code of a program that was circulating on a forum, in some functions it used return -1 and in others it used return 1.
Short answer: It's up to you.
Long Answer:
It depends on you, it can make a lot of difference. the return of a function is a message that is sent from the called function to the function that invoked it and there are not only the values -1 0 and 1 when you talk about an int function, keep in mind that the values of int range from -2,147,483,648 to 2,147,483,647. so why limit yourself to -1 to 0 to 1. Well partly because they are simple numbers but in programming you are the programmer and you have the power .
So for example you can do a sum function;
and there you see how important the return is...
Or you can manage your own secret code
However, if you are not interested at all, if you don't capture that value and start asking yourself those kinds of questions, I recommend that you do the void function and then you won't have those existential dilemmas