Write a method that finds the product of an array or set of numbers sent as a parameter and prints
i can't wrote this
2 Replies
using System.Data;
using System.Text;
namespace hasil
{
public class calculate
{
static void arr()
{
Console.Write("How many numbers do you want to multiply?:");
int limit = Convert.ToInt32(Console.ReadLine());
int[] number = new int[limit];
for (int i = 0; i < limit; i++)
{
Console.Write($"Number{i + 1}:");
number[i] = Convert.ToInt32(Console.ReadLine());
}
Console.Write("----------------------\nResult: ");
for (int i = 0; i < limit; i++)
{
Console.Write($"{number[i]}");
Console.Write("*");
}
Console.WriteLine();
int d = 1;
for (int i = 1; i <= limit ; ++i)
{
d*=number[i];
Console.WriteLine(i);
}
}
public static void Main()
{
arr();
}
}
}
using System.Data;
using System.Text;
namespace hasil
{
public class calculate
{
static void arr()
{
Console.Write("How many numbers do you want to multiply?:");
int limit = Convert.ToInt32(Console.ReadLine());
int[] number = new int[limit];
for (int i = 0; i < limit; i++)
{
Console.Write($"Number{i + 1}:");
number[i] = Convert.ToInt32(Console.ReadLine());
}
Console.Write("----------------------\nResult: ");
for (int i = 0; i < limit; i++)
{
Console.Write($"{number[i]}");
Console.Write("*");
}
Console.WriteLine();
int d = 1;
for (int i = 1; i <= limit ; ++i)
{
d*=number[i];
Console.WriteLine(i);
}
}
public static void Main()
{
arr();
}
}
}
might wanna look into the hell world interactive tutorial