© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
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 ?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ returning an integer in array form
C#CC# / help
4y ago
✅ putting an object from an array into a variable changes the array
C#CC# / help
3y ago
❔ Exclude items from linq query if they contain one from an array of substrings
C#CC# / help
3y ago