C# program for Return Statement

This is the basic program which gives the return value from the caller.

We can also create subtraction, division, multiplication…etc program, respectively by using the following codes.

NOTE:- Student must also try the other subtraction, division, multiplication to grab control and also to be more clear about the “Return Statement” program.

ENJOY CODING!!!
__________________________________________________________________________________

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Return_statement
{
    class PostSlush
    {
        public int add(int a, int b)
        {
            // returns the add of a and b
            return a + b;
        }
        static void Main(string[] args)
        {
            PostSlush p = new PostSlush();
            int result;
            // calling the function add that will return 10 to the result variable.
            result = p.add(1, 9);
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}

Output :

 

Share Your Comments
Previous C# Program to execute Stack Operations
Next C# Program to multiply to matrices using Rectangular arrays

About author

Aamir Shaikh
Aamir Shaikh 1705 posts

<p>A Blogger, SEO Analyst and passionate Web Developer from India.<br /> Believes in hard work and continues working to achieve success.</p>

View all posts by this author →

You might also like