adplus-dvertising
frame-decoration

Question

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

namespace CompSciBitsConsoleApplication
{ 
    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;
        } 
    } 
}
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.
It will output 25 125.
It will output 25 0.
It will output 0 125.
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

Posted under C# programming

Answer: (d).1, 5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

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