Correct starting code



  • In terms of rules and standards, is my code correct?

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter please x: ");
            int x = int.Parse(Console.ReadLine());
            int answer = (int)(x * x + Math.Sin(x + 1)) / (x - 2);
            Console.WriteLine(answer);
    
        firstOne();
        secondOne();
    }
    
    public static void firstOne()
    {
        Console.WriteLine("Enter please x: ");
        int x = int.Parse(Console.ReadLine());
        int answer = (int)(Math.Sqrt(Math.Pow(x, 4) + Math.Sqrt(Math.Abs(x + 1))));
        Console.WriteLine(answer);
    }
    
    public static void secondOne()
    {
        Console.WriteLine("Enter please a: ");
        int a = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter please b: ");
        int b = int.Parse(Console.ReadLine());
        int answer = (((int)Math.Pow(a, 2)) + ((int)Math.Pow(b, 2))) / (1 - (((int)Math.Pow(a, 3)) - b) / 3);
        Console.WriteLine(answer);
    }
    

    }



    1. In the C#, it's commonly referred to as a big letter (as you have Main).
    2. Demonstration of the access retrofit is desirableprivate Main not available).
    3. User input exemptions should be processed if You use it. int.Parse()or use int.TryParse()



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2