You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
391 B
C#

/*
* C# Program to Find the Sum of first 50 Natural Numbers
* using For Loop
*/
using System;
class program
{
public static void Main()
{
int num, sum = 0;
for (num = 1; num <= 50; num++)
{
sum = sum + num;
}
Console.WriteLine("Sum = {0}", sum);
Console.ReadLine();
}
}
/*
Sum = 1275