Microsofts C Language Write a program sumcs with a function
Microsoft\'s C# Language:
Write a program sum.cs with a function int sum(int n) to print the sum of numbers from 1 to 10. Use the mcs compiler to compile it, and run the executable with the mono command.
Solution
The program would be as below:
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 
 class Sum
 { public int sum(int n)
 { int i, sum = 0;
 for (i = 1; i <=10; i++)
 {
 sum = sum + i;
 }
 }
 static void Main(string[] args)
 { int sumNumber;
 Sum s = new Sum();
 sumNumber = s.sum(10);
   
 Console.WriteLine(\"\ Sum of Numbers from 1 to 10 is : \" + sumNumber );
 Console.ReadLine();
 
 }
 }
And to compile and run it via mono command
mcs sum.cs
The compilet will create sum.exe which we can execute as below
mono sum.exe

