Phonem
Phonem
CC#
Created by Phonem on 6/9/2023 in #help
✅ classes giving me an error for no reason
40 replies
CC#
Created by Phonem on 11/5/2022 in #help
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;
}
}
}
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;
}
}
}
8 replies