+ 1
whats wrong with this code?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int[ ] a = new int[10]; for (int k = 0; k < 10; k++) { a[k] = k*2; } //I HAVE WRITTEN K<10 IN THE ABOVE CODE BUT OUTPUT IS SHOWING GREATER THAN 10 TOO for (int k = 0; k < 10; k++) { Console.WriteLine(a[k]); } } } } // THE ABOVE CODE IS NOT GIVING ANY OUTPUT
2 Answers
+ 1
hi Raptor Bot
is this what you want your code to do?
https://code.sololearn.com/c47a5964H1Ib/?ref=app
+ 2
What do you mean it's not giving any output? It displays the contents of the array just fine.
Is there a condition that you need to check before the numbers are inputted in the array? What is your intended output?