Open Notepad
Write a sample program
Write bellow code in notepad and save as Test.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter N number");
int n = Convert.ToInt32(Console.ReadLine());
int i = 0, sum=0;
for (i = 0; i <= n; i++)
{
sum = sum + i;
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter N number");
int n = Convert.ToInt32(Console.ReadLine());
int i = 0, sum=0;
for (i = 0; i <= n; i++)
{
sum = sum + i;
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
save this file in C Drive.
Next open Visula Studio Command prompt.
set the directory in Visual studio Command Prompt
now enter
C:\>CSC Test.cs
Enter
Enter N
3
Then the result
0+1+2+3= 6
No comments:
Post a Comment