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
amit kaushal
NA
3
1.4k
error in code
Jul 10 2013 5:55 AM
// i want to enter numbers in the array by taking size of array as input from user and then allowing user to enter nos. in the array//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n;
int[] a = new int[n];
Console.WriteLine("enter the size of an array");
n = int.Parse(Console.ReadLine());
Console.WriteLine("you can enter "+n+ " numbers in an array");
for (int i = 0; i <= n; i++)
{
a[i] = Console.Read();
}
for (int i = 0; i <= n; i++)
{
Console.WriteLine(a[i]);
}
Console.ReadLine();
}
}
}
i am not able to run this code also not able to understand the errors which are as follows:-
1) use of unassigned local variable n.
2) System.IndexOutOfRangeException.
3) index was outside the bounds of the array
i want to know the meaning of each error and why they are coming.
Reply
Answers (
5
)
Alarming Software
Database design, or parameter/query issue in Lightswitch ?