[Solved] Why is the wrong value being calculated

Two issues: 1) 060 is actually octal which in decimal is 48. So, remove all leading zeros. 2) Inside calculateCost change: if (line[0] == “Mo” || line[0] == “Tu” || line[0] == “We” || line[0] == “Th” || line[0] == “Fr”) to: if (day == “Mo” || day == “Tu” || day == “We” || … Read more

[Solved] How to change place of the next bits?(use only bit operations)

From what I see, it seems that you need a function that swaps position of every 2 bits in a number. few examples: 10’00’11’01’01 -> 01’00’11’10’10 11’01’10’10’11 -> 11’10’01’01’11 for this operation, a very simple function is following: unsigned int change_bit(unsigned int num) { return ((num & 0xAAAAAAAA) >> 1) | ((num & 0x55555555) << … Read more

[Solved] Passing an integer as the argument of a constructor function

In main, queen(ent);, rather than creating a temporary queen using the constructor taking an int, tries to create a queen object called ent using the default constructor. Since ent already exists as an int the compiler throws an error. The solution is to create the object like this: queen q(ent); 3 solved Passing an integer … Read more

[Solved] Valgrind getting strange error

First of all and most importantly: This is not good C++ code, not even decent. For example, some of your #includes are wrong, like <stdio.h> should be <cstdio> instead. The worst thing here are those #defines that make your code utterly unreadable. You really should read a good book on C++! For better readability I … Read more

[Solved] Ant in a Cuboid find shortest path: length, width and height of a cuboid are given. Output should display the shortest distance in floating point [closed]

You made a mistake in the formulae. The way you’re looking at it, you should write: (a + sqrt(b^2 + c^2)) (b + sqrt(a^2 + c^2)) (c + sqrt(a^2 + b^2)). And even then, you wouldn’t get the shortest distance. To give an example, suppose the cube is of 1x1x1 units with sides along the … Read more

[Solved] SQL parameters not working

You’re not actually running the command. You need to call ExecuteNonQuery or ExecuteScalar: using (var cmd = new SqlCommand(query, conDataBase)) { // set parameters… cmd.ExecuteNonQuery(); } 1 solved SQL parameters not working

[Solved] Cannot implicitly convert type ‘Systems.Collections.Generic.List C# JSON [duplicate]

Your JSON string is for an array of Songs’s. So you should try to deserialize to that var songs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Songs>>(reponse); Assuming reponse is a string which has the JSON string you have in your question 10 solved Cannot implicitly convert type ‘Systems.Collections.Generic.List C# JSON [duplicate]