[Solved] sum up an array of integers in C# [closed]

It isn’t clear what you want… If you want to sum some numbers so that the sum stops summing when it reaches 1002 you can: List<int> list = new List<int> { 4, 900, 500, 498, 4 }; var lst = list.Skip(2).Take(3); int sum = 0; foreach (int num in lst) { int sum2 = sum … Read more

[Solved] Please tell whats the error… why it’s not compiling?

Use this printf(“%s” , word); instead of printf(“%s” , *word); Because the *word will be the value at word[0] which is a character. The printf however is looking for an array of chars, thus causing it to segfault. strings are just arrays of characters terminating with ‘\0’. 1 solved Please tell whats the error… why … Read more

[Solved] C++ no equal sign but compiles without assigning value

If ERR_NOT_OK is defined as -41, then your ret_value ERR_NOT_OK; is substituted with ret_value -41; which is a valid expression statement, even though it is effectively a no-op. What was originally intended as unary – gets interpreted as binary – in this context. This is why it is a good idea to define it as … Read more

[Solved] AES encryption on file over 1GB

You are reading the entire file at the start of the method: byte[] bytesToBeEncrypted = File.ReadAllBytes(file); This is causing the OutOfMemoryException. Here’s an idea of how you’d do this: static void EncryptFile(string file, string password) { byte[] passwordBytes = Encoding.UTF8.GetBytes(password); byte[] salt = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; … Read more

[Solved] Trouble with Inheritance c# [closed]

Remove the getter and setter of your private campusName and rename your public campusName to CampusName. Add following code in your Campus class public override string ToString() { return CampusName() + “\n is located at ” + ShowAddress() + “\n it has ” + Departments(); } You should write a base School class public class … Read more

[Solved] Counting down in increments of 5 [closed]

Two things: Fix the while condition: you are only interested in numbers above 20 You need to decrement the counter variable. See the changes below: while (counter > 20) { // Subtract 5 from the counter. counter -= 5; // Print the value of the counter on a line by itself. printf(“%d\n”, counter); } 0 … Read more

[Solved] Error in a function call [closed]

“I ran the code below but it is not working” is not a useful description of your problem. Why is this so? Can anyone please explain this. Your problem is clearly described in the compiler error report, which you should include in your post. error: no matching function for call to ‘NumberOfPennies(int)’ std::cout << NumberOfPennies(4) … Read more

[Solved] Crazy ambiguous thing

I think the problem is absence of const qualifier in QSharedPointer<AbstractDownloadPersistentInfo>argument. So in the first case shared pointer need to go through an extra conversion which turns to be ambiguous. I guess this will be a simplified example. Template constructor of foo makes both variants of bar a viable overloads so ambiguity occurs even though … Read more

[Solved] Textbox into Label [closed]

Here label1 is a Label That you placed in the UI, And you are trying to assign a string value to that control. Such assignment is not valid and not permitted. Your requirement is to assign alPos as the Text property of the Label Control. So your query should be like the following: label1.Text = … Read more

[Solved] Stuck in infinite loop C#

The problem is your use of while loops. while(note != 1) There is nothing in the body of those loops that change that condition. So everytime the loop goes “okay… is note not equal to 1?”.. that condition is always true. So the loop executes again. solved Stuck in infinite loop C#