C# Programming - Functions and Subroutines - Discussion

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

20. 

Which of the following statements are correct about the C#.NET program given below?

namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[ ] args)
        { 
            int a = 5;
            int s = 0, c = 0; 
            s, c = fun(a); 
            Console.WriteLine(s +" " + c) ;
        }
        static int fun(int x)
        {
            int ss, cc;
            ss = x * x; cc = x * x * x; 
            return ss, cc;
        } 
    } 
}
  1. An error will be reported in the statement s, c = fun(a); since multiple values returned from a function cannot be collected in this manner.
  2. It will output 25 125.
  3. It will output 25 0.
  4. It will output 0 125.
  5. An error will be reported in the statement return ss, cc; since a function cannot return multiple values.

[A]. 1, 3
[B]. 2, 4
[C]. 4, 5
[D]. 1, 5
[E]. None of these

Answer: Option D

Explanation:

No answer description available for this question.

Rajesh said: (Nov 1, 2012)  
Multiple functions values mentioned is wrong and ss, cc has to be pass as an argument.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.