Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace random
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] happiness = { 10, 15, 22, 30 }; //Initialize array of happiness values
- ImproveHappiness(happiness); //Call ImproveHappieness method to increase all values in array by 2
- foreach (int happy in happiness) //Print new values to console.
- {
- Console.WriteLine(happy);
- }
- Console.Read();
- //Output: 12, 17, 24, 32
- }
- // Method to increase each value in array by 2
- static void ImproveHappiness(int [] happyvalue)
- {
- for (int i = 0; i < happyvalue.Length; i++)
- {
- happyvalue[i] += 2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement