C
C#7mo ago
Arone

❔ returning an array from a substring

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { internal class Program { static int[] studentMarks = new int[5]; static int[] percentage = new int[5]; static void Main(string[] args) {
InputAllMarks(); ConvertToPercentage(); for (int i = 0; i < 5; i++) { Console.WriteLine(percentage[i]); }
Console.ReadLine(); } static void InputAllMarks() { for (int i = 0; i < 5; i++) { Console.WriteLine("Please enter your marks"); studentMarks[i] = int.Parse(Console.ReadLine()); } } static int[] ConvertToPercentage() { for (int i = 0; i < 5; i++) { percentage[i] = studentMarks[i] / 60 * 100;
} return percentage; } } } Can anyone tell me why this returns 0 in The array percentage ?
6 Replies
Murten
Murten7mo ago
$code
MODiX
MODiX7mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
SinFluxx
SinFluxx7mo ago
ints don't do decimals, they only do whole numbers
WEIRD FLEX
WEIRD FLEX7mo ago
it's time to use floats
Arone
Arone7mo ago
Oh lmao yeah I’m stupid
Accord
Accord7mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
✅ Creating new cancellation token from multiple other tokensI've got function that is being passed in a cancellation token, and I want to cancel an inner functi✅ oauth in asp net framework?hi all, i have created a redirect url for oauth clients how can i redirect my deployed asp net pro❔ Best, most reliable NER (Named Entity Recognition) Library for .NET?I'm looking for a NER library that is supported with .net framework & .net core. I do not want to ❔ Organized Function / method libraries?In C# i want to try making some reusable methods/functions. In Unreal Engine, there is a "Function L✅ How do you control which WPF property is the default for that class?Examine the following XAML: ```XAML <SomeClass> PropertyValue </SomeClass> <OtherClass> <OtherCl❔ ✅ WPF Class derivation where both classes have XAML pagesIs it OK for base WPF class to have a XAML page and its derived class to also declare one? So we'd ❔ Adding up checkBoxes and Radio Buttons into list boxhttps://gyazo.com/797f6e3e82d121c43a5895520421ebb3 This is my form looking for some help getting my ❔ Hostbuilder, WPF and adding more class library'sI have my WPF project where i use hostbuilder to handle some dependency's, this works good with anot❔ Why isn't one of my Identity user field being updated?Code: https://gist.github.com/JsPeanut/b59cc1d4da3ababc532fe3b6e8a9ad69 The void `ChangeUserCategor❔ 0x80070422 error when starting UWP projectHello!!!!!!!! So when I try to start an UWP project in Visual Studio, it does not work and the follo