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
array as parameters
Dec 19 2018 12:44 PM
write a Separate method should take an integer array and swap the element in that array until it contains the even numbers sorted followed by the odd number sorted.
For example and array containing 3, 4, 2, 1, 5 should end us as 2, 4, 1, 3, 5.
using System;
namespace HelloWorld
{
class Program
{
static string GetArrayAsString(int[] array)
{
if(array.Length == 0) return "";
string str = "";
int i = 0;
for(; i < array.Length - 1; i++)
{
str += array[i] + ", ";
}
str += array[i];
return str;
}
static void Main(string[] args)
{
int[] numbers = {3, 4, 2, 1, 5};
Separate(numbers);
Console.WriteLine(GetArrayAsString(numbers));
}
}
}
Reply
Answers (
1
)
Count of Occurence of Characters in str without using Loop
Printing a receipt