You are not logged in. Please login at to post your questions!


getting runtime error c#

static int count; static List<int> numbers = new List<int>(); static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine());

        int k = Convert.ToInt32(Console.ReadLine());

        for (int i = 0; i < 5; i++)
            numbers.Add(Convert.ToInt32( Console.ReadLine()));
        foreach (var item in numbers)
            if (item % k == 0)

asked 19 Feb, 14:54

cod_rush's gravatar image

accept rate: 0%

You might be running your program without any inputs and getting a Runtime Eception , DivideByZeroException. This is because the default value assigned to k will be zero if you are not reading the value of k as input. Try giving some inputs and you wonn't get any runtime error, except when k=0. :)

This answer is marked "community wiki".

answered 19 Feb, 19:55

satyapriya98's gravatar image

accept rate: 0%

wikified 19 Feb, 20:01

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 19 Feb, 14:54

question was seen: 49 times

last updated: 19 Feb, 20:01