C# Programming - Functions and Subroutines

Why should I learn to solve C# Programming questions and answers section on "Functions and Subroutines"?

Learn and practise solving C# Programming questions and answers section on "Functions and Subroutines" to enhance your skills so that you can clear interviews, competitive examinations, and various entrance tests (CAT, GATE, GRE, MAT, bank exams, railway exams, etc.) with full confidence.

Where can I get the C# Programming questions and answers section on "Functions and Subroutines"?

IndiaBIX provides you with numerous C# Programming questions and answers based on "Functions and Subroutines" along with fully solved examples and detailed explanations that will be easy to understand.

Where can I get the C# Programming section on "Functions and Subroutines" MCQ-type interview questions and answers (objective type, multiple choice)?

Here you can find multiple-choice C# Programming questions and answers based on "Functions and Subroutines" for your placement interviews and competitive exams. Objective-type and true-or-false-type questions are given too.

How do I download the C# Programming questions and answers section on "Functions and Subroutines" in PDF format?

You can download the C# Programming quiz questions and answers section on "Functions and Subroutines" as PDF files or eBooks.

How do I solve C# Programming quiz problems based on "Functions and Subroutines"?

You can easily solve C# Programming quiz problems based on "Functions and Subroutines" by practising the given exercises, including shortcuts and tricks.

Exercise : Functions and Subroutines - General Questions
  • Functions and Subroutines - General Questions
1.
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 num = 1;
            funcv(num); 
            Console.Write(num + ", "); 
            funcr(ref num); 
            Console.Write(num + ", ");
        }
        static void funcv(int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        }
        static void funcr (ref int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        } 
    } 
}
1, 1, 1, 1,
11, 1, 11, 11,
11, 11, 11, 11,
11, 11, 21, 11,
11, 11, 21, 21,
Answer: Option
Explanation:
No answer description is available. Let's discuss.

2.
What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        { 
            int[]arr = newint[]{ 1, 2, 3, 4, 5 }; 
            fun(ref arr);
        }
        static void fun(ref int[] a)
        { 
            for (int i = 0; i < a.Length; i++)
            { 
                a[i] = a[i] * 5; 
                Console.Write(a[ i ] + " "); 
            } 
        } 
    } 
}
1 2 3 4 5
6 7 8 9 10
5 10 15 20 25
5 25 125 625 3125
6 12 18 24 30
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
Which of the following statements are correct?
  1. An argument passed to a ref parameter need not be initialized first.
  2. Variables passed as out arguments need to be initialized prior to being passed.
  3. Argument that uses params keyword must be the last argument of variable argument list of a method.
  4. Pass by reference eliminates the overhead of copying large data items.
  5. To use a ref parameter only the calling method must explicitly use the ref keyword.
1, 2
2, 3
3, 4
4, 5
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
A function returns a value, whereas a subroutine cannot return a value.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.

5.
Which of the following statements are correct about functions and subroutines used in C#.NET?
  1. A function cannot be called from a subroutine.
  2. The ref keyword causes arguments to be passed by reference.
  3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.
  4. A subroutine cannot be called from a function.
  5. Functions and subroutines can be called recursively.
1, 2, 4
2, 3, 5
3, 5
4, 5
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.