Write a program in C# that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student.
Following is the simple C# code :
Following is the simple C# code :
class Lab { static void Main(string[] args) { int sum=0, total = 500; float per; Console.Write("\nEnter marks of 5 subjects with comma seprated : "); var smarkes = Console.ReadLine(); var arrymarkes = smarkes.Split(','); for (int i = 0; i < arrymarkes.Length; i++) { sum+= Convert.ToInt32(arrymarkes[i]); } per = (sum * 100) / total; Console.WriteLine("The sum of markes: "+sum); Console.WriteLine("\nPercentage: "+per); Console.ReadLine(); } }
No comments:
Post a comment