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
C# Corner
Tech Writer
8
1.4k
how to declare a method
Dec 15 2018 5:54 PM
write a method called GetOddEvenSumDifference that takes an array of integers and returns the sum of all the even numbers minus the sum of all the odd numbers.
(e.g. an array containing 6, -2, 3, 5, 8 will return 4, which is (6 + -2 + 8) - (3 + 5).
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int[] numbers = {6, -2, 3, 5, 8};
int result = GetOddEvenSumDifference(numbers);
Console.WriteLine(result);
}
}
}
Reply
Answers (
1
)
bit of maths problem
passing parameters with out