adplus-dvertising

Welcome to the Functions and Subroutines MCQs Page

Dive deep into the fascinating world of Functions and Subroutines with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Functions and Subroutines, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Functions and Subroutines, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Functions and Subroutines. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Functions and Subroutines. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Functions and Subroutines MCQs | Page 2 of 3

Q11.
Which of the following statements are correct about functions used in C#.NET?

1. Function definitions cannot be nested.
2. Functions can be called recursively.
3. If we do not return a value from a function then a value -1 gets returned.
4. To return the control from middle of a function exit function should be used.
5. Function calls can be nested.
Discuss
Answer: (a).1, 2, 5
Q12.
How many values is a function capable of returning?
Discuss
Answer: (a).1
Q13.
What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            object[] o = new object[] {"1", 4.0, "CompSci", 'B'};
            fun (o);
        }
        static void fun (params object[] obj)
        {
            for (int i = 0; i < obj.Length-1; i++)
            Console.Write(obj[i] + " ");
        }
    }
}
Discuss
Answer: (c).1 4 CompSci
Discuss
Answer: (d).0
Q15.
Which of the following CANNOT occur multiple number of times in a program?
Discuss
Answer: (b).Entrypoint
Q16.
What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i;
            int res = fun(out i);
            Console.WriteLine(res);
        }
        static int fun (out int i)
        {
            int s = 1;
            i = 7;
            for(int j = 1; j <= i; j++)
            {
                s = s * j;
            }
            return s;
        } 
    } 
}
Discuss
Answer: (d).5040
Q17.
If a function fun() is to sometimes receive an int and sometimes a double then which of the following is the correct way of defining this function?
Discuss
Answer: (a).static void fun(object i)
{ ... }
Q18.
Which of the following statements are correct about subroutines used in C#.NET?

1. If we do not return a value from a subroutine then a value -1 gets returned.
2. Subroutine definitions cannot be nested.
3. Subroutine can be called recursively.
4. To return the control from middle of a subroutine exit subroutine should be used.
5. Subroutine calls can be nested.
Discuss
Answer: (b).2, 3, 5
Q19.
A function can be used in an expression, whereas a subroutine cannot be.
Discuss
Answer: (a).True
Q20.
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.
Discuss
Answer: (d).1, 5
Page 2 of 3

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!