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.
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
Explore more Topics under C# Programming
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.
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] + " ");
}
}
}
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;
}
}
}
{ ... }
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.
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.
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!