Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Array Manipulation Fun in C#! 🔢

Hey there! 👋 Welcome to this repository where we explore the exciting world of arrays in C#. Think of arrays as organized boxes where you can store multiple items of the same type. This code demonstrates some fundamental things you can do with these boxes!

What This Code Does 🛠️

This program is like a mini array workshop! It guides you through the following steps:

  1. Filling the Boxes 📦: It will ask you to enter ten whole numbers (integers). Each number you type will be placed into one of the ten "boxes" in our array.

  2. Getting the Stats 📊: Once all the boxes are filled, the program will do some quick calculations for you:

    • Average: It will figure out the average value of all the numbers in the boxes.
    • Maximum: It will find the largest number among all the boxes.
    • Minimum: It will find the smallest number among all the boxes.
  3. Putting Them in Order sıralama: Finally, it will take a copy of your numbers and arrange them in ascending order (from the smallest to the largest). It then shows you the sorted list.

How to Run This Code 🚀

If you have .NET 8 installed on your computer (which seems like you do, great!), running this code is a breeze:

  1. Save the Code: Make sure you've saved the code you provided as a file named Program.cs in a folder (let's say you named it ArrayManipulation).

  2. Open Your Terminal: Open your Ubuntu terminal and navigate to the ArrayManipulation folder. You can use the cd command (change directory). For example:

    cd ArrayManipulation
  3. Run the Magic Command: Type the following command and press Enter:

    dotnet run

    This command tells .NET to build and run your C# code.

  4. Follow the Instructions! 📝: The program will then prompt you to enter ten integer values one by one. Just type a number and press Enter after each one. Once you've entered all ten numbers, it will display the calculated average, maximum, minimum, and the sorted list of your numbers.

A Little Look Inside 👀

Here's a simplified breakdown of what's happening in the code:

  • namespace ArrayManipulation: This is like a main folder that keeps our code organized.
  • class Program: Inside the namespace, Program is the blueprint for our application.
  • static void Main(string[] args): This is the starting point of our program. Everything inside this method is executed when you run the code.
  • int[] numbers = new int[10];: This line creates an array named numbers that can hold 10 integer values. Think of it as creating 10 empty boxes next to each other.
  • for loop: This helps us to do something repeatedly. In this case, it loops 10 times to ask you for each number.
  • do-while loop and int.TryParse(): This is a clever way to make sure you enter a valid whole number. It keeps asking until you type something that can be understood as an integer.
  • CalculateAverage(int[] numbers): This is a separate tool (a method) that takes our array of numbers and calculates their average.
  • FindMax(int[] numbers): This tool goes through the array and finds the biggest number.
  • FindMin(int[] numbers): This tool goes through the array and finds the smallest number.
  • SortArrayAscending(int[] numbers): This tool uses a simple method called "Bubble Sort" to arrange the numbers in increasing order. It compares nearby numbers and swaps them if they are in the wrong order, repeating this until everything is sorted.
  • Console.WriteLine() and Console.Write(): These are like the program's way of talking to you and displaying information on the screen.
  • Console.ReadKey(): This line makes the program wait for you to press a key before closing the console window, so you have time to see the results.

Have Fun Exploring Arrays! 🎉

This is a basic introduction to using arrays in C#. There's a lot more you can do with them, but this gives you a good starting point for storing and working with collections of data! Enjoy experimenting! 😊

About

Array Manipulation using C#. Very useful practice so deep

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages