Product of a number
Last updated:
8/23/2020
⁃
Difficulty:
Easy
Create a program in C# which asks the user for two integer numbers and displays their multiplication, but not using the operator *.
You must use consecutive sums.
Input
3
4
Output
3x4= 12
Solution
using System;
public class ProductOfNumber
{
public static void Main(string[] args)
{
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int result = 0;
int i = 0;
while (i < y)
{
result = result + x;
i++;
}
Console.WriteLine("{0}x{1}= {2}", x, y, result);
}
}