Advertisement
lmarkov

Array Of 20 Integers

Jan 24th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. /*
  2.  * 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.
  3. */
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace ArrayOfIntegers
  12. {
  13.     class ArrayOfIntegers
  14.     {
  15.         static void Main()
  16.         {
  17.             int[] arrayOfIntegers = new int[20];
  18.             int multiplier = 5;
  19.  
  20.  
  21.             for (int i = 0; i < arrayOfIntegers.Length; i++)
  22.             {
  23.                 arrayOfIntegers[i] = i * multiplier;
  24.                 Console.WriteLine("{0,2}) {1} * {2} = {3}", i+1, i, multiplier, arrayOfIntegers[i]);
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement