Function Question in C# program

Question

Write a Program in C# to Create a function for the Sum of two number 

Enter a first number : 5

Enter  second number : 5

Expected Output 

The Sum of two number is : 10


solution:-

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ConsoleApplication14

{

    class Program

    {

        public static int sum (int a,int b)

        {

            int Total;

             Total= a + b;

             return Total;



        }

        static void Main(string[] args)

        {

            Console.WriteLine("Enter first Number");

            int n1 =Convert.ToInt32( Console.ReadLine());

            Console.WriteLine("Enter Second Number");

            int n2 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(sum(n1, n2));

           Console.ReadLine();

        

       }

    }

}



Comments

Popular posts from this blog

ANCHOR TAG.HTML

Multiplication of three numbers in C#

switch in c#