Question
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
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?
Similar Questions
Discover Related MCQs
Q. A function can be used in an expression, whereas a subroutine cannot be.
View solution
Q. 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?
View solution
Q. Which of the following CANNOT occur multiple number of times in a program?
View solution
Q. How many values is a subroutine capable of returning?
View solution
Q. How many values is a function capable of returning?
View solution
Q. 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.
View solution
Q. 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?
View solution
Q. 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?
View solution
Q. A function returns a value, whereas a subroutine cannot return a value.
View solution
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!