C
C#•2y 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;
}
}
}
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;
}
}
}
3 Replies
Phonem
Phonem•2y ago
the output
ero
ero•2y ago
you also need to call your cube() method you never use it
Phonem
Phonem•2y ago
forgor 💀 where do i put it okay i got it
namespace kodlama_bilmiyorum
{
class Program
{
static void Main(string[] args)
{

Console.Write("Enter a number: ");
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(cube(num));
}
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 num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(cube(num));
}
static int cube(int num)
{
int result = num * num * num;
return result;
}
}
}
if anyone wants the right solution