C# program to find sum of two number using function

Category > CSHARP || Published on : Monday, November 2, 2020 || Views: 630 || find sum of two number using function


Here Pawan Kumar will explain C# program to find sum of two number using function

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication8
{
    class Sumof
    {
        static void Main(string[] args)
        {
            int a, b;
            Console.Write("Enter 1st Number  ");
            a = int.Parse(Console.ReadLine());
            Console.Write("Enter 2nd Number ");
            b = int.Parse(Console.ReadLine());
            int c = sum(a, b);
            Console.WriteLine("Sum of " + a + " & " + b + " is =" + c);
            Console.ReadLine();
        }
        static int sum(int a, int b)
        {
            int c = a + b;
            return c;
        }
    }
}