TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lovemore Kutseya
NA
21
3.8k
passing parameters with ref
Jan 4 2019 5:40 AM
write the method called currentLargestSum which takes an array of integers and another integer result, passed using the ref keyword.
If the sum of the numbers in the array is larger than the current result then assign the sum to the result. Otherwise leave result unchanged
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int largestSum = 0;
int[] numbers1 = { 10, 12, 3, 2, 45, 6 };
currentLargestSum(numbers1, ref largestSum);
string result = largestSum + ", ";
int[] numbers2 = { 10, 1, 3, 2, 45, 6 };
currentLargestSum(numbers2, ref largestSum);
result += largestSum + ", ";
int[] numbers3 = { 104, 132, 13, 2, 45, 6 };
currentLargestSum(numbers3, ref largestSum);
result += largestSum;
Console.WriteLine(result);
}
}
}
Reply
Answers (
2
)
I want to ask question about .net framework.
problems in insertion