C#C
C#4y ago
Phonem

user input number error

im trying to make a thing where you get user input as a number and get the cube of it. i tried making this but it prints out the number you put in. how can i fix this?

namespace kodlama_bilmiyorum
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter a number: ");
            int result = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(result);


        }
        static int cube(int num)
        {
            int result = num * num * num;
            return result;
        }
    }
}
Was this page helpful?