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
Sun Light
NA
54
7.4k
C# ARRAY Program
Nov 3 2016 12:36 PM
Hi all,
///Program for new element to be added in array
int[] arr1 = new int[] {2,3,4,5,6};
int m, n;
Console.Write("Input the value to be inserted in array:");
m = Convert.ToInt32(Console.ReadLine());
Console.Write("Input the position,where the value to be inserted in array:");
n = Convert.ToInt32(Console.ReadLine());
/* Move all data at right side of the array */
for (int i = arr1.Length; i >= n; i--)
arr1[i] = arr1[i -1];
/* insert value at given position */
arr1[n - 1] = m;
Console.Write("New array is:");
for(int i =0;i <arr1.Length;i++)
{
Console.Write("{0} ", arr1[i]);
}
Console.ReadLine();
///********************************************
Can someone help me for this program.Its showing me error on arr1[i] = arr1[i -1] ; "index was outside the bounds of array."how can i solve it.pls help.
Thanks
Reply
Answers (
3
)
registration error
Recursive function with Sql Data Base