NOTE: I need only the output. Please give both the answers. Thanks for your help. 7. Read the following code snippet: st

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

NOTE: I need only the output. Please give both the answers. Thanks for your help. 7. Read the following code snippet: st

Post by answerhappygod »

NOTE: I need only the output. Please give both theanswers. Thanks for your help.
7. Read the following code snippet:
string s = ".NETCore"; char[] arr = s.ToCharArray();
Stack<char>stack = new Stack<char>(); foreach(char c in arr) {
stack.Push(c);
}
for(int i = 0; i< arr.Length; i++) { arr = stack.Pop();
}
s = newString(arr); Console.WriteLine(s);
The output will be:
8. Read the following code snippet:
public staticdouble Double(double value) { return 2 * value;
}
public staticdouble Square(double value) { return value * value;
}
public static voidTest() { List<Func<double, double>> list =
newList<Func<double, double>>() { Double, Square };Process(list, 16);
}
private static voidProcess(List<Func<double,double>> funcs, double value){
double result;
foreach(var actionin funcs) { result = action(value); Console.Write(
$"{action.Method.Name}({value}) ={result}. ");
}
}
The output will be:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply