+ 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

8th Feb 2019, 4:58 PM
Raptor Bot
Raptor Bot - avatar
2 Answers
+ 1
hi Raptor Bot is this what you want your code to do? https://code.sololearn.com/c47a5964H1Ib/?ref=app
8th Feb 2019, 8:13 PM
Ollie Q
Ollie Q - avatar
+ 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?
8th Feb 2019, 6:26 PM
Lambda_Driver
Lambda_Driver - avatar