Advertisement
TanyaPetkova

C# Part II Arrays Exercise 1

Dec 19th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. //Write a program that allocates array of 20 integers and initializes each element by its index multiplied by 5. Print the obtained array on the console.
  2.  
  3. using System;
  4.  
  5. class MultipliedIndex
  6. {
  7.     static void Main()
  8.     {
  9.         int[] array = new int[20];
  10.  
  11.         for (int i = 0; i < array.Length; i++)
  12.         {
  13.             array[i] = i * 5;
  14.         }
  15.  
  16.         Console.WriteLine(string.Join(", ", array));
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement