C# Programming - Functions and Subroutines - Discussion

Discussion :: Functions and Subroutines - General Questions (Q.No.9)


If a procedure fun() is to receive an int, a Single & a double and it is to return a decimal then which of the following is the correct way of defining this procedure?

fun(int i, Single j, double k) decimal 
{ ... }
static decimal fun(int i, Single j, double k) 
{ ... }
fun(int i, Single j, double k) 
    return decimal; 
static decimal fun(int i, Single j, double k) decimal 
{ ... }
[E]. A procedure can never return a value.

Answer: Option E


No answer description available for this question.

Andrew Cope said: (Oct 29, 2013)  
Bad question. C# programmers shouldn't use the term 'procedure'. They are functions or methods.

Tipu said: (Mar 31, 2014)  
Why not C# methods return a value?

Fred said: (Apr 16, 2014)  
What about :

void fun (int i, Single j, double k, out decimal m) ?

Raghvendra Singh said: (Dec 5, 2014)  
"out" parameter is used to return single or multiple values in case of declaring a function as void (no return type).

Alek said: (May 5, 2015)  
There is no such thing as procedure in C#.

Anindita said: (Aug 28, 2017)  
Let's assume the procedure as method or function, so I tried with this following code, and it is working fine:

namespace Testreturntype
class Program
static void Main(string[] args)
Console.Write(fun(5, 2, 2.00));

public static decimal fun(int a, Single s, double k)
decimal d = Convert.ToDecimal(a * s * k);
return d;

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.