Skip to content

Instantly share code, notes, and snippets.

@AmirMahdyJebreily
Created June 21, 2023 18:18
Show Gist options
  • Save AmirMahdyJebreily/b5087b28e7b09367248056106a489943 to your computer and use it in GitHub Desktop.
Save AmirMahdyJebreily/b5087b28e7b09367248056106a489943 to your computer and use it in GitHub Desktop.

Revisions

  1. AmirMahdyJebreily created this gist Jun 21, 2023.
    39 changes: 39 additions & 0 deletions Avg.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    // Code Agha => https://github.com/AmirMahdyJebreily
    Console.Write("Enter dads count here : ");
    Console.ForegroundColor = ConsoleColor.Cyan;
    int count = int.Parse(Console.ReadLine());
    int[] dads = new int[count];
    Console.ResetColor();

    Console.WriteLine();
    for (int i = 0; i < count; i++)
    {
    Console.Write($"\tEnter dad no.{i} here : ");
    Console.ForegroundColor = ConsoleColor.Cyan;
    dads[i] = int.Parse(Console.ReadLine());
    Console.ResetColor();

    }

    // کیسه
    float sum = 0;

    foreach (int dad in dads)
    {
    sum += dad;
    }

    float avg = (float)(sum / count);

    Console.WriteLine($"\n\nSum is : {sum}");
    Console.WriteLine($"Avg is : {avg}");


    // int.Parse(string); float.Parse(string);
    // float & double & decimal
    // $"Hello {kobra}"
    // (float)(sum / count)


    // float => int : 1/999999999 => 1
    // string ×> int : "abc123" => ????