[Solved] Swap number bug

As others have pointed out, you can only have one return statement from a function and thus only return on parameter (although it can be a structure). In this instance I would pass the integer values into the function by using integer pointers and passing their address e.g.: int swapNum(int *num1, int *num2); int main() … Read more

[Solved] C# get pair closest to value [closed]

You want something like this: public static Pair FindClosest(IEnumerable<Pair> list, int value) { Pair closest = null; if (list != null && list.Count() > 0) { foreach (var pair in list) { if (value <= pair.Max) { closest = pair; break; } } if (closest == null) { closest = list.Last(); } } return closest; … Read more

[Solved] Push and select data from Array of Objects

besides lack of info provided , this might help you build your own var dataQuestions = [ { question : 1, response : 3, },{ question : 2, response : 7, },{ question : 3, response : 5, }]; function addQ(){ var question = parseInt(document.getElementById(“question”).value); var response = parseInt(document.getElementById(“response”).value); dataQuestions.push( { question: question, response : … Read more

[Solved] How can I solve this String length problem?

Have you tried calculating the length within the function rather than in the console log? This ensures that all of the logic is first completed within the function before it is returned in the console log. Your function expects the string name, but you are passing name.length function getNameLength(name){ return name.length; } console.log(getNameLength(‘John’)); console.log(getNameLength(‘Argentina!’)); console.log(getNameLength(‘Macedonia’)); … Read more

[Solved] how do i send a private message to all people who have a certain role? (discord.js) [closed]

You can use the Role.members property. // get role by name const role = message.guild.roles.cache.find(role => role.name === ‘<roleName>’); // send a message to everyone with the role role.members.each(user => user.send(‘This is a DM’)); This method assumes you have a way to get the <roleName> value from a string; perhaps with an args variable. solved … Read more

[Solved] I don’t understand this hash-function code

The purpose of a hash function ist to retrieve a unique value for a given sequence (of bytes, characters, …). Therefore you need the length of the sequence, here with ‘strlen’. Without bit shift operator (<<) you would get the same result for the sequence ‘abc’ and ‘cba’. The xor operator (^) ‘scrambles”https://stackoverflow.com/”hashes’ the current … Read more

[Solved] I am a Python noob and I cannot get the correct output for a tutorial. Can you direct me to the syntax for my function call [closed]

I believe that you are trying for these : the_array = [] while True: sval = input(‘Enter a number: ‘) if sval == ‘done’: break try: ival = int(sval) the_array.append(ival) except: print(‘Invalid input’) continue def maximum(values): num1 = 0 for i in values: if i >= num1: num1 = i return num1 def minimum(values): num2 … Read more

[Solved] What is difference between using a colon (:) when creating a class to use inheritance and the ‘using’ keyword at the top of the program code?

What is difference between using a colon (:) when creating a class to use inheritance and the ‘using’ keyword at the top of the program code? solved What is difference between using a colon (:) when creating a class to use inheritance and the ‘using’ keyword at the top of the program code?