[Solved] TypeError “int” in Python

You can rewrite the function like below: def concatenate_list_data(list): result=”” for element in list: result += str(element) return result my_result = concatenate_list_data([1, 5, 12, 2]) # leads to 15122 Another approach to the same can be using a list comprehension: to_join = [1, 5, 12, 2] output=””.join([str(i) for i in to_join]) 1 solved TypeError “int” … Read more

[Solved] Why can I convert from int ** to int * in the case of the two-dimensional array, but not in the case of the array of pointers

You might want to learn how these objects are laid out in memory: int array[][3] = { {1,2,3}, {4,5,6}, {7,8,9} }; int *p_array = (int *) array; This creates an object array of type int[][3] in memory (in this case stack) physically laid out in a hypothetical (16-bit word size) architecture as: array 0x8000: 0x0001 … Read more

[Solved] Python int() to the nearest value

int() truncates float values, removing the non-integral portion of the number. You are looking for rounding instead. You can use the round() function for that: >>> round(4.99) 5 solved Python int() to the nearest value

[Solved] ArrayIndexOutOfBoundsException in ten’s complement arithmetic implementation

Okay, after so much discussion and so many issues with your code I have totally revised your original code because you said you wanted to learn more. Among other improvements I have done the following changes: Meaninfgul class name Meaningful method and parameter names Convert repeated and often used constants like 50 and the array … Read more

[Solved] addition of positive and negative numbers

The first println is trying to say I’m gonna sum numbers from 1 to 10 but be careful to add the even numbers as negative numbers So as the even numbers are negative, The code is trying to first check if it’s an even number by (j % 2 == 0) If it’s an even … Read more

[Solved] Boards equals 0 [closed]

int[] numbers = new int[5]; .. System.out.println(numbers[0]); That would print 0 as well. An array of integers without setting a value will have 0 by default. If you receive x = 480, y = 360, num2 = 2 (we don’t know num1), lets assume num1=1 X[num1-1] = x; Y[num1-1] = y; this would be X[1-1] … Read more

[Solved] Is it somehow possible to check if points `x` and `y` is in a line when only the y-intercept and the slope is given? [closed]

Yes, it is possible, however, this has nothing to do with programming and is more of a mathematical question. (I would recommend going here https://math.stackexchange.com/) Solving this using basic Algebra, given the slope and y-intercept we can check if a point is on a line by substituting the x and y values. For example, if … Read more

[Solved] I have a string with a number and a letter, is there a way to move the integer into a separate int variable? [closed]

You could split over a specific string (degree character for example), store in a String array and parse the first element. Something like this: String str = “47°C” String[] strArray = str.split(“°”); int number = Integer.parseInt(strArray[0]); solved I have a string with a number and a letter, is there a way to move the integer … Read more

[Solved] Can not flip sign

You can’t do it in a completely portable way. Rather than dealing with int64_t, let us consider int8_t. The principle is almost exactly the same, but the numbers are much easier to deal with. I8_MAX will be 127, and I8_MIN will be -128. Negating I8_MIN will give 128, and there is no way to store … Read more

[Solved] incompatible types: String cannot be converted to int even there’re no strings [closed]

You are passing two arguments as String type, “20”, “10”: int myBmi = myBmiCal(“20”, “10”); But it should be int type: int myBmi = myBmiCal(20, 10); “” – it means just empty String in Java. “20” – it means String with value 20. “20” and 20 are different types in Java. Here is documentation to … Read more