• Functions and Subroutines - General Questions
6. 

Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        {
            int a = 5; 
            int s = 0, c = 0;
            Proc(a, ref s, ref c);
            Console.WriteLine(s + " " + c);
        }
        static void Proc(int x, ref int ss, ref int cc)
        {
            ss = x * x;
            cc = x * x * x;
        } 
    } 
}

A. 0 0
B. 25 25
C. 125 125
D. 25 125
E. None of the above

7. 

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 10;
            double d = 34.340;
            fun(i);
            fun(d);
        }
        static void fun(double d)
        {
            Console.WriteLine(d + " ");
        }
    }
}

A. 10.000000 34.340000
B. 10 34
C. 10 34.340
D. 10 34.34

8. 

Which of the following statements are correct?

  1. C# allows a function to have arguments with default values.
  2. C# allows a function to have variable number of arguments.
  3. Omitting the return value type in method definition results into an exception.
  4. Redefining a method parameter in the method's body causes an exception.
  5. params is used to specify the syntax for a function with variable number of arguments.

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

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?

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

10. 

If a function 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 function?

A.
decimal static fun(int i, Single j, double k)
{ ... }
B.
decimal fun(int i, Single j, double k)
{ ... }
C.
static decimal fun(int i, Single j, double k)
{ ... }
D.
static decimal fun(int i, Single j, double k) decimal
{ ... }
E.
static fun(int i, Single j, double k)
{ 
    ... 
    return decimal;
}