[Solved] Why doesn’t ++ increment integer value?

Because the expression num1++ evaluates to num1. You may want to do: ++num1 which evaluates to num1 + 1. Note however that both expressions increment num1 by one. Evaluating num1 in the next statement evalutes to the incremented value. In short In C, why doesn’t num1++ increment in the printf()? num1++ does increment num1 but … Read more

[Solved] Error CS0030: Cannot convert type ‘void’ to ‘double’

Modify your function and use it like in example below. using System; public class Program { public static double Decode(string a) { return double.Parse(a); } public static void Main() { var decoded = Decode(“2.1”); Console.WriteLine(decoded); } } OUTPUT: 2.1 If you want improve this function read about Double.TryParse. solved Error CS0030: Cannot convert type ‘void’ … Read more

[Solved] Why the C++ code couldn’t display bitmap?(code from textbook) [closed]

Running your code, put aside the code logic first, just to show the BMP image, you did not add the correct image path. You can try to add the absolute path of the picture. Like this: DrawBitmap(“C:\\Users\\strives\\source\\C.bmp”,x,y); //This is my picture path. Please enter your picture path correctly. Updated: I retested the code with MinGW, … Read more

[Solved] Check if string contains only one type of letter C# [closed]

Try this: private bool ContainsOnlyOneLetter(string String) { if(String.Length == 0) { return true; } for(int i = 0; i < String.Length;i++) { if(String.Substring(i,1) != String.Substring(0,1)) { return false; } } return true; } And you can use the function like this: bool containsOneLetter = ContainsOnlyOneLetter(“…”); if (containsOneLetter == true) { //Put code here when the … Read more

[Solved] Need Converting Help C# to F#

Something like this should do the trick: let getEnumDescription value = let fi = value.GetType().GetField(value.ToString()) let attributes = fi.GetCustomAttributes(typedefof<DescriptionAttribute>, false) |> Array.map (fun x -> x :?> DescriptionAttribute) if attributes.Length > 0 then attributes.[0].Description else value.ToString() Then you can call it like so: let red = Color.Red |> getEnumDescription let blue = Color.Blue |> getEnumDescription … Read more

[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] 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] 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?

[Solved] What does char a[50][50] mean in C?

char a[50][50] declares a as a 50-element array of 50-element arrays of char. That means each a[i] is a 50-element array of char. It will be laid out in memory like: +—+ a: | | a[0][0] +—+ | | a[0][1] +—+ | | a[0][2] +—+ … +—+ | | a[0][49] +—+ | | a[1][0] +—+ … Read more