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
Mngaro Mwazenje
NA
80
13.1k
swap arrays given by the user
Mar 2 2020 1:41 AM
using
System;
using
System.Collections.Generic;
namespace
exercise_78
{
class
Program
{
public
static
void
Main(
string
[] args)
{
// DO NOT CHANGE THE FOLLOWING CODE!
int
[] array =
new
int
[5];
array[0] = 1;
array[1] = 3;
array[2] = 5;
array[3] = 7;
array[4] = 9;
int
index = 0;
while
(index < array.Length)
{
Console.WriteLine(array[index]);
index++;
}
Console.WriteLine(
""
);
// Implement here
// asking for the two indices
// and then swapping them
Console.WriteLine(
"Give two indices to swap: "
);
int
n = Convert.ToInt32(Console.ReadLine());
int
t = Convert.ToInt32(Console.ReadLine());
// DO NOT CHANGE THE FOLLOWING CODE!
Console.WriteLine(
""
);
index = 0;
while
(index < array.Length)
{
Console.WriteLine(array[index]);
index++;
}
}
}
}
anyone with code how to swap user input arrays
Reply
Answers (
1
)
Csharp method does not save or return any value eventhough
search array n give index