SUM OF SOME NUMBERS USING FOR LOOP......

Unknown | 6:33 AM |

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter limit");
            int limit = Convert.ToInt16(Console.ReadLine());
            int sum = 0;
            for (int i = 0; i <= limit; i++)
            {
                sum = sum + i;
            }
            Console.WriteLine("The sum is :" + sum.ToString());
            Console.WriteLine("end");
            Console.ReadLine();
        }
    }
}


SELECTION OF OPERATIONS.....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the first number.");
            int a = Convert.ToInt16(Console.ReadLine());
            Console.WriteLine("Enter the second number.");
            int b = Convert.ToInt16(Console.ReadLine());
            Console.WriteLine("enter an operation to be performed (+,-,*,/)");
            string o = Console.ReadLine();





using if condition

            if (o.Trim() == "+")
            {
                Console.WriteLine(Convert.ToString(a+b));
            }
            else if (o.Trim() == "-")
            {
                Console.WriteLine(Convert.ToString(a - b));
            }
            else if (o.Trim() == "*")
            {
                Console.WriteLine(Convert.ToString(a * b));
            }
            else if (o.Trim() == "/")
            {
                Console.WriteLine(Convert.ToString(a / b));
            }
                  Console.WriteLine("end");
            Console.ReadLine();
        }
    }
}
Using switch condition
switch (o.Trim())
            {
                case "+":
                    Console.WriteLine(Convert.ToString(a + b));
                    break;
                case "-":
                    Console.WriteLine(Convert.ToString(a- b));
                    break;
                case "*":
                    Console.WriteLine(Convert.ToString(a * b));
                    break;
                case "/":
                    Console.WriteLine(Convert.ToString(a / b));
                    break;


       }
                  Console.WriteLine("end");
            Console.ReadLine();


Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....